Need to delete the previous points in a plot while plotting continously
4 ビュー (過去 30 日間)
古いコメントを表示
During the matlb plotting of some set of points the previous points at previous time step should be deleted and continue with the further plotting.
x = [1,2,3,4,5];
y = [3,4,5,6,7];
plot(x,y,'-o');
so when its plotting for x(2) and y(2), the points of x(1) and y(1) should be deleted/unmarked on the plot.
2 件のコメント
Dyuman Joshi
2023 年 11 月 9 日
Just to be clear - Do you to show one point at a time?
If yes, then what should be the time gap between consecutive points? Should the line be in the background?
If no, then please specify.
採用された回答
Dyuman Joshi
2023 年 11 月 9 日
編集済み: Dyuman Joshi
2023 年 11 月 9 日
Change colors and other properties as you like/prefer.
x = [1,2,3,4,5];
y = [3,4,5,6,7];
plot(x, y, 'r')
hold on
h = animatedline('Marker', 'o', 'Color', 'k');
xlim([0 10])
ylim([0 10])
for k=1:numel(x)
addpoints(h, x(k), y(k));
pause(1)
drawnow
clearpoints(h)
end
3 件のコメント
Dyuman Joshi
2023 年 11 月 9 日
You are welcome!
If my answer solved your problem, please consider accepting the answer.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Animation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!