How to use plot3 and a for loop to gradually plot the 3D graph of values?
14 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!