What is my syntax lacking to achieve an accumulative-progressing animation of the plot?

1 回表示 (過去 30 日間)
hold on
for idx = 1:10
plot(idx, density(idx),"*")
drawnow
xlim([0.0 10.0])
ylim([0.0 6.1])
hold on
plot(1:idx, density(1:idx),"*")
drawnow
end
Unrecognized function or variable 'density'.

採用された回答

Dyuman Joshi
Dyuman Joshi 2024 年 1 月 2 日
I assume you want to add a point to the graph iteration wise.
In that case, try this -
%Sample values
density = rand(1,10);
%Initialize an animated line with specifications as needed
h = animatedline('Marker', '*');
for idx = 1:10
%Add points to the line
addpoints(h, idx, density(idx))
%Update the figure
drawnow
end
  4 件のコメント
Dyuman Joshi
Dyuman Joshi 2024 年 1 月 8 日
You're welcome!
Yes, using pause() is equivalent to calling drawnow, see here - https://in.mathworks.com/help/matlab/ref/drawnow.html?s_tid=doc_ta#burd3gs-3
CHUN HIN KYLE
CHUN HIN KYLE 2024 年 1 月 8 日
編集済み: CHUN HIN KYLE 2024 年 1 月 8 日
Then why did it only work when the equivalent of "drawnow" is repeated?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by