Show more than one figure one by one in MATLAB
I have 20 figures to display one after another like slide show. Can I do it using Imshow in Matlab开发者_开发问答? Any sort of help will be appreciated.
Couple options:
- Open a figure for each plot
- Open and close a figure for each plot
- Reuse one figure
Open a figure for each plot
for i=1:20
h = figure;
%plot here
pause
end
Open and close a figure for each plot
for i=1:20
h = figure;
%plot
pause
close gcf
end
Reuse one figure
h=figure
for i=1:20
clf(h);
%plot
pause
end
OR depending on what you are plotting, you can use the refreshdata method.
If you use @Jonas' method, and if you have dual monitors, you have to force the figure to the main monitor for getframe to actually work, as per. You can do this via:
ff=figure;
movegui(ff)
You can use MOVIE to display plots/images one after the other. For this, you create the figures, capture them via GETFRAME, and then you can call movie
. See this example from the help for getframe
Z = peaks; surf(Z)
axis tight
set(gca,'NextPlot','replacechildren');
for j = 1:20
surf(sin(2*pi*j/20)*Z,Z)
F(j) = getframe;
end
movie(F,20) % Play the movie twenty times
精彩评论