필터 지우기
필터 지우기

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!