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

1 visualizzazione (ultimi 30 giorni)
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'.

Risposta accettata

Dyuman Joshi
Dyuman Joshi il 2 Gen 2024
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 Commenti
CHUN HIN KYLE
CHUN HIN KYLE il 8 Gen 2024
Modificato: CHUN HIN KYLE il 8 Gen 2024
Then why did it only work when the equivalent of "drawnow" is repeated?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Animation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by