x=0:pi/100:2*pi;
y=sin(x);
plot(x,y)
axis tight
set(gca,'nextplot','replacechildren');
% Record the movie
for j = 1:20 
    plot(x,sin(2*pi*j/20)*y)
    F(j) = getframe;
end
% Play the movie two times
movie(F,2)
