MATLAB: Are movie frames clipped at the figure boundaries when I use the MOVIE function to play a movie in MATLAB

"hiddenMATLABmoviepartialportionshow

I use the following code to create a movie:
r = subplot(2,1,1)
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
s = subplot(2,1,2)
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
% Record the movie
for j = 1:20
axes(r)
surf(sin(2*pi*j/20)*Z,Z)
axes(s)
surf(sin(2*pi*(j+5)/20)*Z,Z)
F(j) = getframe(gcf);
pause(.0333)
end
When I play the movie using the following commands, the movie frames are clipped at the boundaries of the figure.
figure(2);
movie(F,20);

Best Answer

The MOVIE function does not automatically resize the figure. Therefore, if the dimensions of the movie frames are large, the movie appears clipped at the figure boundaries.
To work around this issue, resize the figure before playing the movie, as shown below:
[h, w, p] = size(F(1).cdata); % use 1st frame to get dimensions
hf = figure;
set(hf, 'position', [42 42 w h]); % resize figure based on frame's dimensions
movie(hf, F, 1, 30, [0 0 0 0]); % tell MOVIE command to place frames at bottom left