how to place a 2D section in 3d map?

34 ビュー (過去 30 日間)
Lilya
Lilya 2025 年 2 月 10 日 10:53
回答済み: Lilya 2025 年 2 月 12 日 10:24
I have a section ot temperature data that want to place it in a 3D map
any help will be apprecited.
this is to plot the map
figure
surf(Xlon,Ylat,Zdep)
shading interp
Zlimit=[-2800 2800];
colormap(cmap)
dem1 = demcmap(Zlimit,128)
view(20,70);
axis([32 37 26 30 -2800 2800])
caxis([-2800 2800])
hold on
xlabel('Longitude [\circE]','fontsize',14)
ylabel('Latitude [\circN]','fontsize',14)
zlabel('Depth [m]','fontsize',14)
colorbar
% and this for the section:
pcolor(Xgrid2(:,xl),Zgrid(:,xl),chl(:,xl,2));
shading interp
c=colorbar;
caxis([0 0.4])
axis([5 80 -350 0])
colormap(cchl);
set(gca, 'Xdir', 'reverse')
  1 件のコメント
Mathieu NOE
Mathieu NOE 2025 年 2 月 10 日 12:49
hello
pls share some data along , it's much more efficient to get some help from the community :)

サインインしてコメントする。

採用された回答

Karan Singh
Karan Singh 2025 年 2 月 12 日 8:27
Hi @Lilya,
There are some things that needs to be taken care of-
As Mathieu correctly stated we need some data to continue, I have written down a code considering some dummy data for the same.
% Dummy data for 3D map
[Xlon, Ylat] = meshgrid(32:0.1:37, 26:0.1:30); % Longitude and latitude grid
Zdep = -2800 + 5600 * rand(size(Xlon)); % Random depth values between -2800 and 2800
% Dummy data for temperature section
xl = 1:50; % Index for the section
Xgrid2 = linspace(32, 37, 50); % Longitude values for the section
Zgrid = linspace(-350, 0, 20); % Depth values for the section
chl = 0.4 * rand(20, 50); % Random temperature values (20 depths x 50 longitudes)
% Define the latitude for the section
Ylat_section_value = 28.5; % Fixed latitude for the section
% Plot the 3D map
figure;
surf(Xlon, Ylat, Zdep, 'EdgeColor', 'none');
shading interp;
colormap(jet); % Use a colormap for the map
Zlimit = [-2800 2800];
caxis(Zlimit);
view(20, 70);
axis([32 37 26 30 -2800 2800]);
xlabel('Longitude [\circE]', 'fontsize', 14);
ylabel('Latitude [\circN]', 'fontsize', 14);
zlabel('Depth [m]', 'fontsize', 14);
colorbar;
hold on;
% Prepare the temperature section for 3D
[Xlon_section, Zdep_section] = meshgrid(Xgrid2, Zgrid); % Create grid for section
Ylat_section = repmat(Ylat_section_value, size(Xlon_section)); % Repeat latitude for section
% Plot the temperature section in 3D
surf(Xlon_section, Ylat_section, Zdep_section, chl, 'EdgeColor', 'none');
shading interp;
colormap(parula); % Use a different colormap for the section
caxis([0 0.4]); % Adjust color limits for temperature
colorbar;
% Adjust depth direction
set(gca, 'Zdir', 'reverse');
% Add transparency to the temperature section (optional)
alpha(0.7);
% Final adjustments
view(20, 70);
axis([32 37 26 30 -2800 2800]);
title('3D Map with Temperature Section', 'fontsize', 16);
Karan

その他の回答 (1 件)

Lilya
Lilya 2025 年 2 月 12 日 10:24
Thank you very much! This is very helpful.
Just one small thing: the dimensions of Xgrid2 and Zgrid are 251 by 28. When I use meshgrid, it results in a 7028 by 7028 array, which is incorrect. How can I correct this mistake so that everything has dimensions of 251 by 28?

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by