How do I do multi animated lines in one axes?
Afficher commentaires plus anciens
I need to do two multi animated lines in one axes.Is there any solution to this problem? As picture shows: This picture use "plot" ,but It's slowly when close to the end. And the matlab give a suggestion :use animatline to instead the plot function.

Réponse acceptée
Plus de réponses (2)
I suggest to you another approach, i think it is familiar to anyone. You can use "hold on" after "figure" And, of course, at the moment, "update" in "drawnow is no need. I will use example that Thorsten is given. Of course, to reduce cost time, i use 1000 to replace for 100000.
numpoints = 1000;
x = linspace(0,4*pi,numpoints);
y = sin(x);
y2 = cos(x);
figure
hold on % To hold this figure.
h = animatedline;
h2 = animatedline;
axis([0,4*pi,-1,1])
for k = 1:numpoints
addpoints(h,x(k),y(k))
addpoints(h2,x(k),y2(k))
drawnow % "update" is no need for this case
end
1 commentaire
srinivas REDDY
le 16 Août 2020
how to save above graph in gif format ?
vlad gnatenko
le 23 Déc 2018
0 votes
What if u need 2 lines in 2 Figures?
Catégories
En savoir plus sur Animation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!