how to plot 4D date of 3 vectors and one 3D array

4 次查看(过去 30 天)
I have a 3D array (date) the three 3 different vectors ((Ny,Nx,Nz). I would like to show the data
Scatter3 can not used with negative values
and surf can not be used with vector
i do not know how i can show the data
  2 个评论
Dyuman Joshi
Dyuman Joshi 2023-11-8
" I would like to show the data"
In what form? A surface?
"Scatter3 can not used with negative values"
Yes, because you are using the data in the 3D array as color and size values. Those, by definition, can not be negative.
Abdullah
Abdullah 2023-11-9
yes i a surface form
but surface can no be used with vectors,
i attached a picture of workspace and code

请先登录,再进行评论。

回答(1 个)

Pratyush Swain
Pratyush Swain 2023-11-27
Hi Abdullah,
I understand you want to show the data containing 3 different vectors and you also mentioned it contains negative numbers.I suggest using the 'vol3d' function from https://www.mathworks.com/matlabcentral/fileexchange/22940-vol3d-v2?s_tid=srchtitle.
Please find an example implementation as follows:
% Define the dimensions
Ny = 93;
Nx = 53;
Nz = 37;
% Create dummy 3D data with random values including negatives
dummyData = randn(Ny, Nx, Nz);
% Create a figure for 3D visualization
figure;
% Use vol3d to create a 3D volume visualization
h = vol3d('CData', dummyData);
% Set the view to have a better perspective
view(3);
% Adjust the aspect ratio for a better visualization
daspect([2 2 2]);
% Set appropriate axis labels and title
xlabel('X');
ylabel('Y');
zlabel('Z');
title('3D Data Visualization');
Alternatively, you can use the 'slice' function to display 2D slices of data. For more information please refer to https://www.mathworks.com/help/matlab/ref/slice.html
Hope this helps.
  1 个评论
Abdullah
Abdullah 2023-11-29
Hi Pratyush,
thanks for the comment.
i get the error "Unrecognized function or variable 'vol3d'
Anywho i think that man should use the "ndgrid" and "griddedInterpolant" to handle 3d-meshgrid which could be the way to the solution of my problem

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!