Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于组合文件夹中的.fig文件以生成视频/动画的MATLAB代码?_Matlab_Video_Matlab Figure - Fatal编程技术网

用于组合文件夹中的.fig文件以生成视频/动画的MATLAB代码?

用于组合文件夹中的.fig文件以生成视频/动画的MATLAB代码?,matlab,video,matlab-figure,Matlab,Video,Matlab Figure,我正试图从我的系统中的一个文件夹中的一系列图形(.fig)文件中制作一个动画。我提到了问题和建议。 最后,我有代码mkvideo.m: % Creating Video Writer Object writerObj = VideoWriter('peqr.avi'); % Using the 'Open` method to open the file open(writerObj); % Creating a figure. % Each frame will be a figure da

我正试图从我的系统中的一个文件夹中的一系列图形(.fig)文件中制作一个动画。我提到了问题和建议。 最后,我有代码
mkvideo.m

% Creating Video Writer Object
writerObj = VideoWriter('peqr.avi');
% Using the 'Open` method to open the file
open(writerObj);

% Creating a figure.
% Each frame will be a figure data
Z = peqr;
surf(Z); 
axis tight
set(gca,'nextplot','replacechildren');
set(gcf,'Renderer','zbuffer');
[figures,var] = uigetfile('*.fig','Multiselect','on');

for k = 1:length(figures) 
   Multi_Figs = [var,filesep,figures{k}];
   Op = openfig(Multi_Figs);
   % Frame includes image data
   frame = getframe;
   % Adding the frame to the video object using the 'writeVideo' method
   writeVideo(writerObj,frame);
   close(Op);
end
% Closing the file and the object using the 'Close' method
close(writerObj);
我得到以下错误

Warning: No video frames were written to this file. The file may be invalid. 
> In VideoWriter/close (line 278)
  In VideoWriter/delete (line 213)
  In mkvideo (line 2) 
Undefined function or variable 'peqr'.

Error in mkvideo (line 8)
Z = peqr;
我想这段代码应该能够在用户界面上生成一次视频,我选择的文件是什么


如果我能得到一些帮助来纠正此代码中的错误,以便能够制作动画或视频,那将非常有帮助。

当您执行
Z=peqr在第8行,似乎未定义
peqr
。它是在代码的其他地方定义的吗?在这一行中,我可能认为-
writerObj=VideoWriter('peqr.avi')
2行/定义变量
writerObj
。只需删除
open(writerObj)
行和
uigetfile
行之间的所有代码。这是用于绘制不需要的图形的代码,因为您已经有了带有图形的.fig文件。是否所有
fig
文件都具有相同的宽度和高度?如果没有,则必须将人物的
位置
设置为希望动画的某个宽度和高度。根据数字的数量和您希望显示帧的时间,您还可以选择创建一个,它允许您轻松设置每帧的延迟。