在创建动画gif时停止Matlab调整表面大小(Stop Matlab from resizing the surface when creating an animated gif)

编程入门 行业动态 更新时间:2024-10-09 07:21:18
在创建动画gif时停止Matlab调整表面大小(Stop Matlab from resizing the surface when creating an animated gif)

我想用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="

本文发布于:2023-07-19 07:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1175408.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表面   大小   动画   Matlab   gif

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!