Plot multiple points in a for loop
Ältere Kommentare anzeigen
Hello everyone, I have a for loop which is plotting different points over a certain amount of time. Right now the previous point is removed when the next one is added, but i would like to keep the old points.
n=100
for i=1:n+1
plot(i,i,'r.','MarkerSize',10);
axis([0 110 0 110])
f(i) = getframe(gcf);
end
Hopefully someone can help me with that.
Akzeptierte Antwort
Weitere Antworten (2)
Steven Lord
am 23 Mai 2017
1 Stimme
Create an animatedline then addpoints to that animatedline each time you step through your for loop.
1 Kommentar
Kasun Kariyawasam
am 29 Nov. 2018
Bearbeitet: Kasun Kariyawasam
am 29 Nov. 2018
Thanks @steven. This was a good solution. Using 'animatedline' rather than 'plot' later allowed me to add different colors and legend entries for each line, which would have been difficult with 'plot'.
Felix Kalscheuer
am 23 Mai 2017
0 Stimmen
Kategorien
Mehr zu Animation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!