Error using getframe.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I am trying to program an AVI on a crank-slider mechanism, but it keeps on showing up this error:
"Error using getframe (line 53)"
"A valid figure or axes handle must be specified"
"Error in Animation (line 33)"
"F=getframe(1);"
I am really new to matlab, so I can't seem to resolve this error.
w = 1.25;
Ampl = 10;
t = [0:1/30:10];
Px = Ampl*cos(w*t);
Py = Ampl*sin(w*t);
AVI = 1;
M_Movie = 0;
if AVI==1
Rotation_Movie = VideoWriter('Rotation_Movie.avi');
open(Rotation_Movie);
end;
for k = 1:length(t);
plot(Px,Py);
hold on;
plot(Px(k),Py(k),'r.','MarkerSize',25);
if k > 5;
plot(Px(k-1),Py(k-1),'r.','MarkerSize',20);
plot(Px(k-2),Py(k-2),'r.','MarkerSize',15);
plot(Px(k-3),Py(k-3),'r.','MarkerSize',10);
plot(Px(k-4),Py(k-4),'r.','MarkerSize',5);
plot(Px(k-5),Py(k-5),'r.','MarkerSize',1);
end;
hold off;
F=getframe(1);
if(AVI);
writeVideo(Rotation_Movie,F);
elseif (M_Movie)
E_movie(k)=F;
end;
end;
if(AVI);
close(Rotation_Movie);
end;
0 commentaires
Réponses (1)
Geoff Hayes
le 30 Oct 2015
Hariharan - rather than using 1 as an input to getframe, why not try using gcf to get the handle to the current figure (which may not be '1' for whatever reason)? Replace your above with
F=getframe(gcf);
3 commentaires
Geoff Hayes
le 31 Oct 2015
Hariharan - back and forth from which point? Do you mean to say that if the Marker reaches a certain angle (relative to the origin) of the circle then it should change direction and so bound back and forth between two points?
Voir également
Catégories
En savoir plus sur Animation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!