%% Specify Frames Per Second
% Specify the number of frames per second at which to play the movie.
% Create a figure object h and initialize the surface plot. Customize the figure axes.

h = figure;
Z = peaks;
surf(Z)
axis tight manual
ax = gca;
ax.NextPlot = 'replaceChildren';

% Preallocate a 40-element array M to store the movie frames.

loops = 40;
M(loops) = struct('cdata',[],'colormap',[]);

% Capture each plot of function X as an individual frame and store them in M.
% Set the 'Visible' property of the figure object to 'off'.

h.Visible = 'off';
for j = 1:loops
    X = sin(j*pi/10)*Z;
    surf(X,Z)
    drawnow
    M(j) = getframe;
end

% Set the 'Visible' property of the figure to 'on'. Play the movie once at 6 frames per second.

h.Visible = 'on';

% movie(M,1,6);
%
% Copyright 2020 The MathWorks, Inc.
%
%