我想用Matlab2013(Linux 64bit)创建一个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[1] http://postimg.org/image/prib1psq5/
I'd like to create a 360 degree rotating surface plot using Matlab2013 (Linux 64bit). I can create an animated gif using code snippet beneath but Matlab keeps resizing the surface at some frames throughout the animation (example see [1], frame 56-59). Any idea how I can prevent Matlab from resizing the plot surface? Thanks in advance for your advice.
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[1] http://postimg.org/image/prib1psq5/
最满意答案
问题是由于轴限制随视图而变化,这可以通过手动设置轴限制或通过将轴属性'XLimMode' , 'YLimMode'和'ZLimMode'为'manual'来'ZLimMode' 。
然而,其他属性(例如DataAspectRatio,PlotBoxAspectRatio等)将导致图形在旋转时放大和缩小
然而,Matlab提供了vis3d轴模式来为您设置所有这些! 您需要添加的是:
axis('vis3d')这应该在设置滴答等之后放置......但是在for循环之外
The problem is caused by the axis limits changing with the view, this could be prevented by manually setting the axis limits or by setting the axis properties 'XLimMode','YLimMode' and 'ZLimMode', to 'manual'.
However other properties (e.g. DataAspectRatio, PlotBoxAspectRatio, etc...) will cause the figure to zoom in and out while rotating
Matlab however provides the vis3d axis mode to set all of this for you! All you need to add is:
axis('vis3d')which should be place after setting ticks etc... but outside the for loop
更多推荐
Matlab,filename,surface,frame,电脑培训,计算机培训,IT培训"/> <meta name="
发布评论