%% Play Movie Frames in Bottom Left Corner of Figure
% Play the movie frames in the bottom left corner of the figure.
% 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',[]);

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

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

% Set the 'Visible' property of the figure to 'on'. Play the movie in M once at 12 frames per second and with an offset of 30 pixels in the x and y directions. Specify handle h to play the movie in the current figure.

h.Visible = 'on';

% movie(h,M,1,12,[30 30 0 0]);
% Copyright 2020 The MathWorks, Inc.
%