Display plots as movie without pause()

2 次查看(过去 30 天)
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 :)

回答(2 个)

Chunru
Chunru 2022-8-24
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 2022-8-24
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

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by