How to graphically represent 3D array

조회 수: 2 (최근 30일)
Dejan Nikolic
Dejan Nikolic 2014년 12월 6일
답변: Amit 2014년 12월 9일
Hi,
I have the following problem:
3d array is generated and consists of 0s and 1s. I need to draw a line (in 3D) which connects all elements which value is 1.
I have tried with plot3 and scatter3 functions, but I haven't achieve any success. The only thing I get is empty space.
I have using following commands:
plot3(Xcoordinate,Ycoordinate,Zcoordinate,'r','linewidth',2)
Or
scatter3(Xcoordinate,Ycoordinate,Zcoordinate,'r','linewidth',2)
X, Y, Zcoordinate are vectors reprsenting axes of a 3d array.
Thank you for your time,
Dejan

채택된 답변

Amit
Amit 2014년 12월 9일
Lets say you have a 3D matrix with m x n x k size.
Then:
[X,Y,Z] = meshgrid(1:m,1:n,1:k);
plot3(X(A == 1),Y(A == 1),Z(A == 1),'r','linewidth',2))
This will do it !

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by