Error. Movie contains uninitialized frames
이전 댓글 표시
I'm trying to make a film with this code:
clc;
clear all;
m1= input('masa 1');
m2= input('masa 2');
L1= input('longitud 1');
L2= input('longitud 2');
g= input('gravedad');
Tfin= input('tiempo final');
DT= input('intervalo de momentos');
alpha= input('angulo alpha');
beta= input('angulo beta');
u= input('velocidad inicial');
%%Cálculos
%%1
NT= Tfin/DT;
C= linspace(0,Tfin,NT);
%%2
X1(1)= L1*sin(alpha);
Y1(1)= -L1*cos(alpha);
X2(1)= X1(1)+L2*sin(beta);
Y2(1)= Y1(1)-L2*cos(beta);
%%3
A= prepara_pend(m1,m2,L1,L2,g,DT);
%%4
V= transpose([alpha,beta,0,0]);
%%5
for J=2:NT
V= A*V;
alpha= V(1);
beta= V(2);
X1(J)= L1*sin(alpha);
Y1(J)= -L1*cos(alpha);
X2(J)= X1(J)+L2*sin(beta);
Y2(J)= Y1(J)-L2*cos(beta);
end
%%6
X=[X1,Y1];
Y=[X2,Y2];
plot(X1,Y1,'r',X2,Y2,'b')
grid on;
legend('X','Y');
%%opcional
for i=2:NT
M(i)=getframe;
end
movie(M)
but it gives me this error:
Error using movie
Movie contains uninitialized frames
how can I fix this?
Please some help, thanks.
답변 (1개)
Walter Roberson
2018년 3월 8일
Where do you assign to M(1) ? You have
for i=2:NT
M(i)=getframe;
end
which starts creating M from M(2)
Note: it would be more efficient to initialize M(NT) to something first so that it would not be necessary to keep increasing the size of M as you ran the loop.
Also note that you are not giving any time for the frames to change, so you are going to be copying the same frame into the movie each time.
댓글 수: 2
Dominique
2022년 6월 23일
Ah! Ah! I made the same mistake.
Matthew Jenkins
2022년 9월 4일
I did as well, thanks!
카테고리
도움말 센터 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!