movie

Plays a sequence of movie frames in a figure.

Category: Graphics > 2-D and 3-D Plots

Syntax

movie(M)

Plays the frames in the struct array M once.

movie(M, n)

Plays the movie n times.

movie(M, n, fps)

Plays at fps frames per second.

Description

A typical animation loop draws a plot, grabs it with getframe, stores the frame in M(k) and, after the loop, calls movie(M). The frames are shown in the current axes, scaled to fit. Frames made with im2frame work as well.

Input arguments

M
Struct array of frames with cdata and colormap fields, from getframe or im2frame.
n
Number of repetitions, 1 by default.
fps
Frame rate in frames per second, 12 by default.

Example

Play generated frames

for k = 1:3
    M(k) = im2frame(uint8(cat(3, 80*k*ones(40), 40*ones(40), 200*ones(40))));
end
movie(M, 2)

In the app, the frames play below the code.

See also

getframe im2frame frame2im drawnow