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

Risposte (1)

Walter Roberson
Walter Roberson il 22 Apr 2012

0 voti

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 Commenti

Alan Manning
Alan Manning il 22 Apr 2012
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.
Alan Manning
Alan Manning il 22 Apr 2012
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.
Image Analyst
Image Analyst il 22 Apr 2012
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.
Jeff Levasseur
Jeff Levasseur il 9 Dic 2019
Wouldn't have guessed it but yes the filename was too long

Accedi per commentare.

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Tag

Richiesto:

il 22 Apr 2012

Commentato:

il 9 Dic 2019

Community Treasure Hunt

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

Start Hunting!

Translated by