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

1 visualizzazione (ultimi 30 giorni)
Lilya
Lilya il 10 Feb 2025
Risposto: Lilya il 12 Feb 2025
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 Commento
Mathieu NOE
Mathieu NOE il 10 Feb 2025
hello
pls share some data along , it's much more efficient to get some help from the community :)

Accedi per commentare.

Risposta accettata

Karan Singh
Karan Singh il 12 Feb 2025
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

Più risposte (1)

Lilya
Lilya il 12 Feb 2025
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?

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by