Error using getframe.
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Geoff Hayes
il 30 Ott 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 Commenti
Geoff Hayes
il 31 Ott 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?
Vedere anche
Categorie
Scopri di più su Animation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!