how to plot 4D date of 3 vectors and one 3D array
4 views (last 30 days)
Show older comments
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 Comments
Dyuman Joshi
on 8 Nov 2023
" 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.
Answers (1)
Pratyush Swain
on 27 Nov 2023
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!