how to plot 4D figure to describe changing in ocean ?

4 ビュー (過去 30 日間)
Amal MM
Amal MM 2024 年 9 月 29 日
コメント済み: Umar 2024 年 10 月 10 日
Hi,
I have the oceanographic data ( Longitude , Latitude , Density ,Depth)
I want to plot the change of density with depth such as the picture
I try to plot with surf but give me the surface changing
Also I try slice but did’t work because my data is 2D
Longitude =300*400,
Latitude =300*400 ,
Density =300*400,
Depth =300*400

回答 (2 件)

Voss
Voss 2024 年 9 月 29 日

"I try to plot with surf but give me the surface changing"

How did you use surf, and what was wrong with the result?

Have you tried the following?

surf(Longitude,Latitude,Depth,Density)
  2 件のコメント
Amal MM
Amal MM 2024 年 9 月 29 日
yes I did it give this plot
I want plot somting similar like this
Voss
Voss 2024 年 9 月 29 日
colormap(jet())

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


Umar
Umar 2024 年 9 月 30 日

Hi @Amal MM ,

After reading through your comments, it seems that your task involves visualizing oceanographic data, specifically the relationship between density and depth across a grid defined by longitude and latitude. The data is structured in a 2D format, but your goal is to create a plot that effectively represents the changes in density with depth. Now, the challenge arises from the need to represent this data in a way that is both informative and visually appealing, while also addressing the limitations of the surf and slice functions in MATLAB.

So, to visualize the oceanographic data effectively, you can utilize MATLAB's scatter3 function to create a 3D scatter plot, where you a represent density as color and depth as the z-axis. This approach will allows you to convey the fourth dimension (density) through color coding, while maintaining a clear representation of the spatial dimensions (longitude and latitude) and depth. Since you mentioned that your data is structured as 300x400 matrices for longitude, latitude, density, and depth, we will create synthetic data for demonstration purposes. Convert the 2D matrices into vectors to facilitate plotting. Use scatter3 to plot the data, where the x-axis represents longitude, the y-axis represents latitude, the z-axis represents depth, and the color represents density. Add labels, a color bar, and a title to make the plot more informative. Here is a complete MATLAB code snippet that implements the above steps:

_% Generate Sample Data_
longitude = linspace(-180, 180, 400); % Longitude from -180 to 180
latitude = linspace(-90, 90, 300);    % Latitude from -90 to 90
[lon, lat] = meshgrid(longitude, latitude); % Create a grid of longitude and   
latitude
_% Create synthetic depth and density data_
depth = rand(size(lon)) * 5000; % Depth values between 0 and 5000 meters
density = 1025 + (depth / 5000) * 5; % Density values, increasing with depth
_% Reshape the Data_
lon_vector = lon(:);
lat_vector = lat(:);
depth_vector = depth(:);
density_vector = density(:);
_% Create the 3D Scatter Plot_
figure;
scatter3(lon_vector, lat_vector, depth_vector, 36, density_vector, 'filled');
view(3); % Set the view to 3D
grid on;

For more information on scatter3 function, please refer to

https://www.mathworks.com/help/matlab/ref/scatter3.html

_% Enhance Visualization_
xlabel('Longitude (degrees)');
ylabel('Latitude (degrees)');
zlabel('Depth (meters)');
title('Density Variation with Depth in Oceanographic Data');
colorbar; % Add a color bar to indicate density values
colormap(jet); % Use a colormap for better visualization

For more information on colormap(jet) function, please refer to

https://www.mathworks.com/help/matlab/ref/jet.html?s_tid=doc_ta

Please see attached.

Feel free to adjust the synthetic data generation to match your actual oceanographic data for more accurate visualizations.

Please let me know if you have any further questions.

  5 件のコメント
Amal MM
Amal MM 2024 年 10 月 10 日
thanx
Umar
Umar 2024 年 10 月 10 日
Hi @Amal MM,
Thank you for your response. I appreciate your acknowledgment. If there’s anything specific you would like to discuss further or if you have additional thoughts, please feel free to share.

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

カテゴリ

Help Center および File ExchangeOceanography and Hydrology についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by