How do I get 3 comets to launch at once?

6 vues (au cours des 30 derniers jours)
Lucy Bailey
Lucy Bailey le 4 Mai 2021
Modifié(e) : Adam Danz le 5 Mai 2021
Hello! I am doing a school project and looking to launch one enemy rocket as a timer begins, then I have to wait 60 secconds for the 3 defence missles to fire. I am struggling to create the loop for this, but I will post what I have! Thanks!
  2 commentaires
Adam Danz
Adam Danz le 4 Mai 2021
Modifié(e) : Adam Danz le 5 Mai 2021
You could try using linkprop to link the coordinates of the 3 rockets so you only have to change one of them (typically these data are stored in xdata and ydata properties). I don't know if that will improve the display lag or not.
dpb
dpb le 5 Mai 2021
Also check out
doc timer
as the clever way to wait and then start the intercept task(s) after the magic time has elapsed.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 5 Mai 2021
You cannot do that with comet() . Each call to comet() does not return until the display is finished.
You will need to use a different approach, such as using animatedline()
  1 commentaire
Adam Danz
Adam Danz le 5 Mai 2021
Modifié(e) : Adam Danz le 5 Mai 2021
Hmmm.... I just noticed that comet only references the first column of data when provided with a matrix of y-values (demo below). Looking under the hood, it doesn't look like it would take too much to adapt it to support multiple columns of data.
x = linspace(-pi,pi,180)';
y = sin([1,2,.5].*x);
figure()
hold on
plot(x,y(:,1), 'k--','LineWidth',1)
comet(x,y)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by