Introduction to MATLAB
Animation
To create animation, first plot each frame and save the data in a corresponding column of a movie matrix, say, M.
>> axis equal
>> M = moviein(16); % allocate/initialize the matrix to have 16 frames
>> set(gca,'NextPlot','replacechildren')
>> for j=1:16
plot(fft(eye(j+16)))
M(:,j) = getframe;
end
Once M is defined for all 16 frames, its time to run the animation.
>> movie(M,30) % run 30 times
|