Effacer les filtres
Effacer les filtres

How to use comet to trace the path of an object?

8 vues (au cours des 30 derniers jours)
reema shrestha
reema shrestha le 8 Juil 2017
Commenté : Image Analyst le 9 Juil 2017
I am writing a code for the simulation of double pendulum and i need to trace the path of the bob. But I am having trouble with it. This is a part of my code. Basically,i am having trouble in this portion. Though I use the command comet,it doesn't trace the path. Anyone who could point out my mistake and help me solve the problem? Here x1(i),y1(i) is the poition of first bob.
for i = 1 : max(arraysize)
plotarrayy = [pendulumtopy y1(i)]; % Plots solution at each time interval
plotarrayx = [pendulumtopx x1(i)];
plotarray2x = [x1(i) x2(i)];
plotarray2y = [y1(i) y2(i)];
plot(x1(i),y1(i),'ro',x2(i),y2(i),'bo','markersize',5,'markerfacecolor','r')
hold on
comet(y1(i));

Réponses (1)

jonatan
jonatan le 8 Juil 2017
comet requires the input(s) to be a vector and not a single value, as you wrote. In order to use this function, you should run it after the for loop:
comet(x1,y1)
  2 commentaires
reema shrestha
reema shrestha le 9 Juil 2017
What should be the input for the comet outside the loop? I tried using
comet(y(i))
But then i only runs inside loop,isn't it??
Image Analyst
Image Analyst le 9 Juil 2017
Outside the loop, it should be what he said it should be:
comet(x1,y1)
Why did you change it?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements 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