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

31 vues (au cours des 30 derniers jours)
Seba.V
Seba.V le 13 Mai 2020
Commenté : KSSV le 13 Mai 2020
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

Réponse acceptée

KSSV
KSSV le 13 Mai 2020
Modifié(e) : KSSV le 13 Mai 2020
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 commentaires
Seba.V
Seba.V le 13 Mai 2020
Thank you KSSV can I ask you what (X(1:i)) does exactly?
KSSV
KSSV le 13 Mai 2020
X(1:i) will pick the array from 1 to i. They are indices.
Thank you is accpeting the answer. :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by