Thursday 6 March 2008

Movies in Matlab

This script shows the very basics on how to generate a movie in Matlab

% Generate a simple movie: plot f(t, x) = sin(x - t) on (0, 2pi) for different t

for i = 1:25

% Make a figure
t = 0.1 * i;
fplot(@(x) sin(x - t), [0 2*pi])

% Store the figure as a frame in the movie
M(i)=getframe;

end

% Play the movie ten times
movie(M,10)