Plot surface from Lat/Lon/Depth/Data with different size depth
6 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I'm sure this question is already answered on this forum, but I can't find any answer that match my problem. So here's the thing:
I need to plot multiple surfaces from different lat, lon and depth coordinates but:
- Lat and Lon are 35x1 vectors
- Depth is a 100x1 vector that apply to all Lat/Lon couple
- Datas are 100x35 matrix (so depending Depth and Lat/Lon)
So when I try to plot with Surf(Lat,Lon,Depth,Data) it does'nt work (logical...). I tried different way to overcome the problem but I never managed to success. My best attempt was to use scatter3 with loops to plot by Lat/Lon couple one by one, but that's not really a perfect solution.
I'm sure there's a trick with meshgrid or repmat but I'm quite new to Matlab, and I can't figure out on my own how the dimension of each vector should imbricate (I understand in 2D, but 3D is out of my range...)
The result should look like this (without the bathymetric map):
Update: In attachment, an exemple of a set of data, lat, lon, depth with 100x108 dimension instead of 100x35, but the idea is the same
回答 (3 件)
Benjamin Thompson
2022 年 3 月 11 日
編集済み: Benjamin Thompson
2022 年 3 月 11 日
This might help with a starting point. Of course you will fill in your own depth data and coordinates.
lat = 35:(1/35):36-1/35;
lon = -100:(1/35):(-99-1/35);
depth = zeros(35,35,100);
depth(:,:,1) = rand(35,35) - 50;
depth(:,:,2) = rand(35,35) - 100;
[LAT, LON] = meshgrid(lat, lon);
figure, surf(LAT, LON, depth(:,:,1));
hold on
surf(LAT, LON, depth(:,:,2));
1 件のコメント
Benjamin Thompson
2022 年 3 月 11 日
You can also use contour3 if you want the contour level lines by themselves, or surfc if you want the surface plus the contour lines.
Star Strider
2022 年 3 月 11 日
Try this —
LD1 = load('Data.mat');
Data = LD1.Us;
LD2 = load('Depth.mat');
Depth = LD2.Depth;
LD3 = load('Lat.mat');
Lat = LD3.lati;
LD4 = load('Lon.mat');
Lon = LD4.long;
DepIdx = @(d) find(Depth < d, 1, 'first');
ChooseDepth = -100; % Choose Nearest 'Depth' To This Value
Depthv = Data(DepIdx(ChooseDepth),:); % 'Depth' Column Corresponding To This Depth
Depthv = fillmissing(Depthv,'linear'); % Interpolate 'NaN' Values
[Lt,Lg] = ndgrid(Lat,Lon); % Matrices For 'griddata' Interpolation
DepSfc = griddata(Lat,Lon,Depthv, Lt,Lg); % Create Surface Matrix
figure
plot3(Lat, Lon, Depthv) % Line Plot
grid on
xlabel('Lat')
ylabel('Lon')
zlabel('Something')
title(sprintf('Depth = %.4f',Depth(DepIdx(ChooseDepth))))
view(-80,30)
figure
surf(Lat,Lon,DepSfc) % Surface Plot
hold on
% contour3(Lat,Lon,DepSfc, 'ShowText','on')
hold off
grid on
xlabel('Lat')
ylabel('Lon')
zlabel('Something')
title(sprintf('Depth = %.4f',Depth(DepIdx(ChooseDepth))))
view(-80,30)
I have no idea what this plots or what I am looking at.
Plotting contours will not work here because the levels are not unique.
.
3 件のコメント
Star Strider
2022 年 3 月 14 日
I would llike to know the code you wrote to plot those, since I obviously missed some dtails with respect to what the data actually are and how to interpret them.
Anabel Von
2023 年 3 月 13 日
Is there a way to plot the data as a surface section and vertical section simultaneously? (see image)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!