我正在使用Octave编写一个在不同时间段绘制函数的脚本。我希望能够创作出这些情节的动画,以便通过时间观察这些变化。用多个图创建动画 - Octave/Matlab
有没有办法做到这一点,以便可能每次以每种情节可以结合创建此动画的方式保存每个情节?
在此先感谢您的建议!
我正在使用Octave编写一个在不同时间段绘制函数的脚本。我希望能够创作出这些情节的动画,以便通过时间观察这些变化。用多个图创建动画 - Octave/Matlab
有没有办法做到这一点,以便可能每次以每种情节可以结合创建此动画的方式保存每个情节?
在此先感谢您的建议!
这有点杂牌组装电脑的,但你可以做以下(在这里工作与倍频4.0.0-RC2):
x = (-5:.1:5);
for p = 1:5
plot (x, x.^p)
print animation.pdf -append
endfor
im = imread ("animation.pdf", "Index", "all");
imwrite (im, "animation.gif", "DelayTime", .5)
基本上,打印所有地块成PDF,每页一个。然后将PDF文件作为图像读取并以GIF形式打印回来。这在Matlab上不起作用(它的imread实现不能处理pdf)。
好吧,我会试试看。 – user3460758
嗯确定不是我正在寻找....我想将它保存到某种电影文件以及添加到演示文稿 – user3460758
@ user3460758定义视频文件?你没有声音,只有图像,所以GIF应该做得很好。它也应该在演示文稿中显示为动画。请注意,您可以使用LoopCount,因此它不会循环播放动画,甚至可以将数组作为DelayTime用于不同的时间间隔。您的解决方案完全是什么问题? – carandraug
这将创建一个gif动画
data=rand(100,100,20); %100 by 100 and 20 frames
%data go from 0 to 1, so lets convert to 8 bit unsigned integers for saving
data=data*2^8;
data=uint8(data);
%Write the first frame to a file named animGif.gif
imwrite(data(:,:,1),'/tmp/animGif.gif','gif','writemode','overwrite',...
'LoopCount',inf,'DelayTime',0);
%Loop through and write the rest of the frames
for ii=2:size(data,3)
imwrite(data(:,:,ii),'/tmp/animGif.gif','gif','writemode','append','DelayTime',0)
end
在MATLAB中,有'getframe'功能。这在Octave中是否也存在? – hbaderts
使用循环并在每次迭代时更新绘图? –
我这样做,但我只是绘制每个功能在同一个情节(不动画)。另外,这不允许我将连续的地块保存为动画 – user3460758