These examples show how to record animations as movies that you can replay.
Create a series of plots within a loop and capture each plot as a frame. Ensure
the axis limits stay constant by setting them each time through the loop. Store the
for k = 1:16 plot(fft(eye(k+16))) axis([-1 1 -1 1]) M(k) = getframe; end
Play back the movie five times using the
Include a slider on the left side of the figure. Capture the entire figure window
by specifying the figure as an input argument to the
figure u = uicontrol('Style','slider','Position',[10 50 20 340],... 'Min',1,'Max',16,'Value',1); for k = 1:16 plot(fft(eye(k+16))) axis([-1 1 -1 1]) u.Value = k; M(k) = getframe(gcf); end
Play back the movie fives times. Movies play back within the current axes. Create a new figure and an axes to fill the figure window so that the movie looks like the original animation.
figure axes('Position',[0 0 1 1]) movie(M,5)