This example is adapted from 'help VideoWriter

mathematics

Description

This example is adapted from 'help VideoWriter'


figure(1); clf; 

% Prepare the new file.

vidObj = VideoWriter('peaks.avi');

open(vidObj);


% Create an animation.

Z = peaks; surf(Z);

axis([1 50 1 50 -10 10]);

set(gca,'nextplot','replacechildren');

currFrame = getframe;

% Determine size of the frame in pixels.

rect = size(currFrame.cdata);


for k = 1:40

   surf(sin(2*pi*k/20)*Z,Z);

   drawnow;


   % Write each frame to the file.

   currFrame = getframe(gcf,[1 1 rect(1:2)]);

   writeVideo(vidObj,currFrame);

end


% Close the file.

close(vidObj);


Instruction Files

Related Questions in mathematics category