MATLAB: Rotate a 3D plot and keep it the same size

3d plotsgifMATLABrotationscaleview settings

I'm creating a GIF from a series of 3D plots, each one rotated from the previous by changing the viewpoint. Here is a snippet that does the frame generation:
for az=0:5:355
view([az,el]);
drawnow;
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind,cm,filename,'WriteMode','append','DelayTime',dt);
end
The problem I'm having is that each frame is magnified to fill the figure window, causing the plot to change size as it rotates. Here is a link to the GIF (it is also attached).
What view settings must I change to keep the 3D surface the same apparent size as I rotate it?

Best Answer

axis vis3d