我正在学习用 Matlab 制作电影。我从互联网上处理了这段代码来制作电影。我正在使用 OS X Mavericks 和 Matlab 2013a。我通常停靠图形窗口。当我运行代码时,我可以完美地看到动画。当我通过使用 movie2avi
或VideoWriter
命令保存电影时。它不会以全帧图形录制电影。相反,我看到了一些图形窗口和我的 Matlab 桌面视图。谁能帮我这个?
clear;
close all;
% Creates a 2D Mesh to plot surface
x=linspace(0,1,100);
[X,Y] = meshgrid(x,x);
N=100; % Number of frames
for i = 1:N
% Example of plot
Z = sin(2*pi*(X-i/N)).*sin(2*pi*(Y-i/N));
surf(X,Y,Z)
% Store the frame
M(i)=getframe(gca); % leaving gcf out crops the frame in the movie.
end
% myVideo = VideoWriter('wavemotion.avi');
% open(myVideo);
% writeVideo(myVideo,M)
% close(myVideo)
% Output the movie as an avi file
%movie2avi(M,'WaveMovie.avi');