Plot multiple points in a for loop
16 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
KL
2017 年 5 月 23 日
n=100
for i=1:n+1
plot(i,i,'r.','MarkerSize',10);
hold on
axis([0 110 0 110])
f(i) = getframe(gcf);
end
hold off
0 件のコメント
その他の回答 (2 件)
Steven Lord
2017 年 5 月 23 日
Create an animatedline then addpoints to that animatedline each time you step through your for loop.
1 件のコメント
Kasun Kariyawasam
2018 年 11 月 29 日
編集済み: Kasun Kariyawasam
2018 年 11 月 29 日
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'.
参考
カテゴリ
Help Center および File Exchange で Animation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!