Clear Filters
Clear Filters

Display plots as movie without pause()

2 views (last 30 days)
Jettae Schroff
Jettae Schroff on 23 Aug 2022
Answered: Walter Roberson on 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 :)

Answers (2)

Chunru
Chunru on 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 on 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

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!