Dur*_*rin 5 matlab plot animation image-processing animated-gif
我想使用 Matlab2013(Linux 64 位)创建一个 360 度旋转曲面图。我可以使用下面的代码片段创建一个动画 gif,但 Matlab 在整个动画中的某些帧处不断调整表面大小(示例参见 [1],第 56-59 帧)。知道如何防止 Matlab 调整绘图表面的大小吗?
预先感谢您的建议。
function createVideo( FigureHandler, filename )
grid on
set(gca,'ZTickLabel',[]);
set(gca,'YTickLabel',[]);
set(gca,'XTickLabel',[]);
for n = 1:360
view(n,66)
zoom off
drawnow
frame = getframe(FigureHandler);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if n == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',0);
end
end
end
Run Code Online (Sandbox Code Playgroud)
该问题是由轴限制随视图变化而引起的,可以通过手动设置轴限制或将轴属性设置为、'XLimMode'和'YLimMode'来防止此问题。'ZLimMode''manual'
但是其他属性(例如 DataAspectRatio、PlotBoxAspectRatio 等)将导致图形在旋转时放大和缩小
然而,Matlab 提供了vis3d轴模式来为您设置所有这些!
您需要添加的是:
axis('vis3d')
Run Code Online (Sandbox Code Playgroud)
应该放在设置刻度等之后...但在 for 循环之外