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 中查找有关 Animation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!