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

조회 수: 2 (최근 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
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 CenterFile Exchange에서 Animation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by