Record Animation for Playback
These examples show how to record animations as movies that you can replay.
Record and Play Back Movie
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
Capture Entire Figure for Movie
Create a colored panel in the figure, and place the axes in the panel before
creating the plot. Capture the entire figure window by specifying the current figure
gcf) as an input argument to the
f = figure; p = uipanel(f,"Position",[0.1 0.1 0.8 0.8],... "BackgroundColor","w"); ax = axes(p); for k = 1:16 plot(fft(eye(k+16))) axis([-1 1 -1 1]) u.Value = k; M(k) = getframe(gcf); end
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)