I am trying to use the movie2avi function in MATLAB. I simply copy the sample program in my MATLAB R2015a:
nFrames = 20;
% Preallocate movie structure.
mov(1:nFrames) = struct('cdata', [],...
'colormap', []);
% Create movie.
Z = peaks; surf(Z);
axis tight manual
set(gca,'nextplot','replacechildren');
for k = 1:nFrames
surf(sin(2*pi*k/20)*Z,Z)
mov(k) = getframe(gcf);
end
% Create AVI file.
movie2avi(mov, 'myPeaks.avi', 'compression', 'None');
But an error message appears:
Error using avi Unexpected Error. Reason: Failed to open file.
Error in audiovideo.internal.aviwriter (line 168) aviobj.FileHandle = avi('open',filename);
Error in movie2avi (line 63) avimov = audiovideo.internal.aviwriter(filename,varargin{:});
Error in MakeMovie (line 36) movie2avi(mov, 'myPeaks.avi', 'compression', 'None');
What's wrong here? Please help.
VideoWriterclass is the way to go. As the documentation states,movie2aviis deprecated. - horchler