Main Content

录制动画用于播放

这些示例演示如何录制可回放的动画。

录制和播放影片

在循环中创建绘图系列并将每个绘图捕获为一帧。通过每次在循环中进行设置确保坐标轴范围为常量。将帧存储到 M 中。

for k = 1:16
	plot(fft(eye(k+16)))
	axis([-1 1 -1 1])
	M(k) = getframe;
end

Plot of the Fourier transform of sixteen different identity matrices

使用 movie 函数播放影片。

figure
movie(M,5)

为影片捕获整个图窗

在图窗中创建一个彩色面板,并在创建绘图之前将坐标区放在该面板中。通过将当前图窗 (gcf) 指定为 getframe 函数的输入参量捕获整个图窗窗口。

f = figure;
p = uipanel(f,"Position",[0.1 0.1 0.8 0.8],...
    "BackgroundColor","w");
ax = axes(p);

for k = 1:16
    plot(fft(eye(k+16)))
    axis([-1 1 -1 1])
    u.Value = k;
    M(k) = getframe(gcf);
end

Plot of the Fourier transform of sixteen different identity matrices within a colored panel

创建一个新的图窗和坐标区来填充图窗窗口,从而让影片看上去像原始动画。

figure
axes("Position",[0 0 1 1])
movie(M,5)

另请参阅

| | | | | |

相关示例

详细信息