Play recorded movie frames
movie function plays
the movie defined by a matrix whose columns are movie frames (usually
movie(M) plays the movie
M once, using the current axes as the
default target. If you want to play the movie in the figure instead
of the axes, specify the figure handle (or
as the first argument:
be an array of movie frames (usually from
movie(M,n) plays the movie
n is negative, each cycle is shown forward then
n is a vector, the first element is
the number of times to play the movie, and the remaining elements
make up a list of frames to play in the movie.
For example, if
M has four frames then
= [10 4 4 2 1] plays the movie ten times, and the movie
consists of frame
4 followed by frame
followed by frame
2 and finally frame
movie(M,n,fps) plays the
fps frames per second. The default is
12 frames per second. Computers that cannot achieve the specified
speed play as fast as possible.
movie(h,...) plays the
movie centered in the figure or axes identified by the handle
Specifying the figure or axes enables MATLAB® to fit the movie
to the available size.
a four-element location vector,
[x y 0 0], where
the lower left corner of the movie frame is anchored (only the first
two elements in the vector are used). The location is relative to
the lower left corner of the figure or axes specified by
in units of pixels, regardless of the object's
getframe function in a loop to record frames of the
peaks function vibrating. Preallocate an array to store the movie frames.
figure Z = peaks; surf(Z) axis tight manual ax = gca; ax.NextPlot = 'replaceChildren'; loops = 40; F(loops) = struct('cdata',,'colormap',); for j = 1:loops X = sin(j*pi/10)*Z; surf(X,Z) drawnow F(j) = getframe; end
To play the movie two times, use
movie function uses a default figure
size of 560-by-420 and does not resize figures to fit movies with
larger or smaller frames. To accommodate other frame sizes, you can
resize the figure to fit the movie.
movie only accepts 8-bit image frames;
it does not accept 16-bit grayscale or 24–bit truecolor image
Buffering the movie places all frames in memory. As a result, on Microsoft® Windows® and perhaps other platforms, a long movie (on the order of several hundred frames) can exhaust memory, depending on system resources. In such cases an error message is issued:
??? Error using ==> movie Could not create movie frame
You can abort a movie by typing Ctrl-C.
movie is not a built-in function. Therefore,
you cannot call
movie using the
Setting the figure
Renderer property to
around limitations of using
getframe with the
on some Windows systems.