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

3 ビュー (過去 30 日間)
Abdullah
Abdullah 2023 年 11 月 8 日
コメント済み: Abdullah 2023 年 11 月 29 日
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!