movie2avi Problems...

Hello. I'm currently having some troubles with creating an avi file from my script I'm using for plotting three functions. The script is given below:
close all
t=linspace(0,pi,100);
x1=(4.813636)*((t-sin(t))/2);
y1=(-4.813636)*((1-cos(t))/2);
x2=0:.1:3;
y2=-(x2.^2);
x3=0:.1:5;
y3=-x3;
figure(1)
plot(x1,y1,x2,y2,x3,y3)
axis equal
P=moviein(10);
fc=0;
for i=1:10
plot(x1(1:10*i),y1(1:10*i),'b',x2(1:3*i),y2(1:3*i),'r',x3(1:5*i),y3(1:5*i),'g');
hold on
plot(x1(10*i),y1(10*i),'k*',x2(3*i),y2(3*i),'k*',x3(5*i),y3(5*i),'k*');
axis([0 8 -9 0])
title('Recording movie...')
xlabel('x-axis')
ylabel('y-axis')
fc=fc+1;
P(fc)=getframe;
hold off
end
movie(P)
movie2avi(P,'Quickest Descent','fps',2)
I'm relatively new to Matlab, and could definitely use some help. I don't understand why the script isn't creating the avi file, but it creates this error message after running (even though the movie plays perfectly fine on its own via movie(P)):
??? Error using ==> avi
Failed to open file.
Error in ==> avifile.avifile at 173
aviobj.FileHandle = avi('open',filename);
Error in ==> movie2avi at 63
avimov = avifile(filename,varargin{:});
Error in ==> Cycloid_xsquared_x at 31
movie2avi(P,'Quickest Descent','fps',2)
Again, any help would be greatly appreciated.
Thanks

Answers (1)

Walter Roberson
Walter Roberson on 22 Apr 2012

0 votes

Either you do not have write permission in that directory, or else there is some difficulty about that particular file name. Does a file happen to already exist with that name? Have you tried using a shorter name, especially one without a space in it?
Are you using Windows 7? If so then which directory is your current directory?

4 Comments

That was the problem. For some reason I wasn't in the correct directory, and I don't know why. Everything works perfectly now, though. Thanks.
That was the problem. For some reason I wasn't in the correct directory, and I don't know why. Everything works perfectly now, though. Thanks.
I'd recommend that you add the .avi extension to the filename, and that you read this part of the FAQ: http://matlab.wikia.com/wiki/FAQ#Where_did_my_file_go.3F_The_risks_of_using_the_cd_function.
Wouldn't have guessed it but yes the filename was too long

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Asked:

on 22 Apr 2012

Commented:

on 9 Dec 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!