下面是一个创建通过生成帧一个简单的动画作为数字序列的一种尝试,保存在.png
格式:未能打印当前图形
clc
clear
close all
% don't display plot : produces error.
%set(0, 'defaultfigurevisible', 'off');
% number of frames.
N = 2;
% generate data sets.
x = linspace(0, 6 * pi, 1000);
y = sin(x);
% run animation.
for i = 1 : N
% create figure.
clf
% hold on % produces error.
plot(x, y, x(i), y(i), 'ro')
% plot(x(i), y(i), 'ro')
grid on
axis tight
title(sprintf('Sine Wave at (%f, %f)', x(i), y(i)))
xlabel('x')
ylabel('y')
drawnow
% create frame name: fr00001.png, etc.
framename = sprintf('output/fr%05d.png', i);
% save current figure in file: output.
print(framename);
end
不过,我得到的唯一的事情是:
Mesa warning: couldn't open dxtn.dll, software DXTn compression/decompression unavailable
GL2PS error: Incorrect viewport (x=0, y=240883432, width=0, height=240885832)
error: gl2ps_renderer::draw: gl2psBeginPage returned GL2PS_ERROR
error: called from
opengl_print at line 172 column 7
print at line 519 column 14
sinewave at line 48 column 3
任何建议,将不胜感激。
注:注释行是故意留下。
1.后来与编码器的帮助下被拼接成电影在.avi
格式。
是for循环相关的你的问题?请构建一个[mcve]。请注意,我无法在MATLAB中重现错误。这可能是一个GL2PS错误。 – m7913d
您的代码在我的PC(Windows 7,使用Octave的GUI版本)上在Octave 4.2.1中正常运行。我只需要创建'output'目录,之后就很好了。 – am304
@ am304我在当前的工作目录中有我的'输出',但它没有被任何'.png'图片填充,他们只是在屏幕上短暂闪烁并停在最后一个(当'N> 2'时) 。 – Ziezi