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

답변 (1개)

Walter Roberson
Walter Roberson 2012년 4월 22일

0 개 추천

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

Alan Manning
Alan Manning 2012년 4월 22일
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 2012년 4월 22일
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 2012년 4월 22일
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 2019년 12월 9일
Wouldn't have guessed it but yes the filename was too long

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

태그

질문:

2012년 4월 22일

댓글:

2019년 12월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by