필터 지우기
필터 지우기

How to use plot3 and a for loop to gradually plot the 3D graph of values?

조회 수: 22 (최근 30일)
Seba.V
Seba.V 2020년 5월 13일
댓글: KSSV 2020년 5월 13일
Hello there!
I have 3 arrays describing a 3D motion XYZ. I would like to plot them gradually to generate a "simulation" of the 3D motion of the point in space.
I have tried to use a for loop with plot3 but it just gives me a blank figure.
Any suggestions?
Thank you in advance.
for i=1:20
plot3(X(i),Y(i),Z(i))
end

채택된 답변

KSSV
KSSV 2020년 5월 13일
편집: KSSV 2020년 5월 13일
figure
hold on
for i=1:20
plot3(X(i),Y(i),Z(i),'.r')
end
You have to use a marker when you are plotting a single point.
Another way.
for i = 1:20
plot3(X(1:i),Y(1:i),Z(1:i),'r')
end
  댓글 수: 2
Seba.V
Seba.V 2020년 5월 13일
Thank you KSSV can I ask you what (X(1:i)) does exactly?
KSSV
KSSV 2020년 5월 13일
X(1:i) will pick the array from 1 to i. They are indices.
Thank you is accpeting the answer. :)

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

추가 답변 (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