How do I get 3 comets to launch at once?

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 Comments

Adam Danz
Adam Danz on 4 May 2021
Edited: Adam Danz on 5 May 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.
Also check out
doc timer
as the clever way to wait and then start the intercept task(s) after the magic time has elapsed.

Sign in to comment.

Answers (1)

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 Comment

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)

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 4 May 2021

Edited:

on 5 May 2021

Community Treasure Hunt

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

Start Hunting!