How do I get 3 comets to launch at once?
Show older comments
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
dpb
on 5 May 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.
Answers (1)
Walter Roberson
on 5 May 2021
0 votes
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)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!