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

4 visualizaciones (últimos 30 días)
Abdullah
Abdullah el 8 de Nov. de 2023
Comentada: Abdullah el 29 de Nov. de 2023
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 comentarios
Dyuman Joshi
Dyuman Joshi el 8 de Nov. de 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.
Abdullah
Abdullah el 9 de Nov. de 2023
yes i a surface form
but surface can no be used with vectors,
i attached a picture of workspace and code

Iniciar sesión para comentar.

Respuestas (1)

Pratyush Swain
Pratyush Swain el 27 de Nov. de 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.
  1 comentario
Abdullah
Abdullah el 29 de Nov. de 2023
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

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!