plot3 a multidimensional array

조회 수: 9 (최근 30일)
Leila Rajabpour
Leila Rajabpour 2023년 2월 9일
댓글: Leila Rajabpour 2023년 2월 13일
Hi everyone.
How I can extract the data of each dimension of multidimensional array to use them as the input for the plot3 function? I have a multidimensional array of size (9*3600*7) and I want to plot it using plot3 or in a 3D shape. I want to have the axis data as x=3600, y=9 and z=7.
Thank you.
  댓글 수: 2
Matt J
Matt J 2023년 2월 9일
Nothing in the post is clear (at least to me).
Leila Rajabpour
Leila Rajabpour 2023년 2월 9일
I rewrote my question to make it clear.

댓글을 달려면 로그인하십시오.

채택된 답변

Sarvesh Kale
Sarvesh Kale 2023년 2월 9일
part 1)
As an example for matrix V, I am using rand function to generate data, here is code to plot your timeseries data
V=rand(9,3600,7); % REPLACE THIS WITH YOUR OWN DATA
figure ;
for i =1:7
plot(V(:,:,i)'); % you have to supply transpose of V, V(:,:,)' is transpose
end
OR
V=rand(9,3600,7); % REPLACE THIS WITH YOUR OWN DATA
figure ;
V = permute(V,[2,1,3]); % we have rearranged the array V, interchanged row and column in each 7 dimensions
for i =1:7
plot(V(:,:,i)); % you have to supply V
end
you can get more information on plot and permute using the following links
part 2) How to plot using plot3 ?
you can get more information on plot3 using following https://in.mathworks.com/help/matlab/ref/plot3.html
plot3(X,Y,Z) plots coordinates in 3-D space.
  • To plot a set of coordinates connected by line segments, specify X, Y, and Z as vectors of the same length.
  • To plot multiple sets of coordinates on the same set of axes, specify at least one of X, Y, or Z as a matrix and the others as vectors.
V(:,1,1) % will give you first column of first slice
  댓글 수: 1
Leila Rajabpour
Leila Rajabpour 2023년 2월 13일
Thank you Sarvesh for the answer. It was really helpful.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by