Create a meshgrid on a 3d plot

3 views (last 30 days)
Ellisis
Ellisis on 6 Apr 2019
Answered: BhaTTa on 14 Aug 2025
Hello,
I have plotted a 3D graph representing a subducting slab. The 3 dimensions are: longitude, latitude and depth.
figure(1) %plot en longitude, latitude, et depth
tri = delaunay(lon,lat);
trimesh(tri,lon,lat,depth);
I'd like to add on it a random triangular mesh grid in black only for specific coordinates : longitude between 273 and 277, latitude between 9 and 12 but most importantly depth from 0 to -50.
Do you have an idea of how I could do that?
Thank you for your help

Answers (1)

BhaTTa
BhaTTa on 14 Aug 2025
Hey @Ellisis, you can refer to the code below:
% Simple dummy data initialization
lon = 270 + 15*rand(500,1); % 500 random longitude points
lat = 5 + 15*rand(500,1); % 500 random latitude points
depth = -200*rand(500,1); % 500 random depth points (negative)
% Your original plot
figure(1)
tri = delaunay(lon,lat);
trimesh(tri,lon,lat,depth);
hold on;
% Add random mesh in specified region
n_points = 80;
rand_lon = 273 + 4*rand(n_points,1); % 273-277
rand_lat = 9 + 3*rand(n_points,1); % 9-12
rand_depth = -50*rand(n_points,1); % 0 to -50
tri_random = delaunay(rand_lon, rand_lat);
trimesh(tri_random, rand_lon, rand_lat, rand_depth, 'EdgeColor', 'k', 'FaceColor', 'none');
xlabel('Longitude'); ylabel('Latitude'); zlabel('Depth');
hold off;

Categories

Find more on Geographic Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!