Filter löschen
Filter löschen

Display plots as movie without pause()

2 Ansichten (letzte 30 Tage)
Jettae Schroff
Jettae Schroff am 23 Aug. 2022
Beantwortet: Walter Roberson am 24 Aug. 2022
My program creates these plots. For simplicity, let's say it's sin(x)sin(y)*cos(t) - a sinusoidal graph in 2D which goes up and down through time. If I want to display this at a certain fps (let's say 10), I would do
t = 0
while true
plot( sin(x)sin(y)(cos(t) ) % this is just psudocode anyways, doesn't matter
pause(.1)
t = t + .1;
end
However, when I change pause(.1) to pause(.01) or even less, Matlab lags, and it doesn't respond when I try to close the figure, because it takes more then .1 seconds to do the calculation. Are there any alternatives to this? I've been struggling with this for awhile, so any help would be appreciated :)

Antworten (2)

Chunru
Chunru am 24 Aug. 2022
t = 0
while true
plot( sin(x)sin(y)(cos(t) ) % this is just psudocode anyways, doesn't matter
%pause(.1)
drawnow % show the plot immediately
t = t + .1;
end

Walter Roberson
Walter Roberson am 24 Aug. 2022
You could pre-calulate the steps and store each one as an image, and then use https://www.mathworks.com/help/matlab/ref/movie.html

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by