荒草 发表于 2010-6-18 18:19:44

求助!Figure destroyed during getframe

本人初学matlab。下面是一段程序。
clear
hf=figure;
t=0:pi/1000:2*pi;
x=2*sin(t);
y=2*cos(t);
h=plot(x,y);
set(h,'LineWidth',3)
axis([-3 3 -3 3]);
title('Clock');
hold on
for j=1:12
    if rem(j-1,12)==0
      hm1=text(1.8*cos(-(j-1)*pi/30+pi/2),1.8*sin(-(j-1)*pi/30+pi/2),'12');
      set(hm1,'FontSize',18);
    else
      hm2=text(1.8*cos(-(j-1)*pi/6+pi/2),1.8*sin(-(j-1)*pi/6+pi/2),int2str(rem(j-1,12)));
      set(hm2,'FontSize',18);
    end
end
x1=;x2=;x3=;x4=[-1.7 -2];
y1=;y2=;y3=[-1.7 -2];y4=;
h11=line(x1,y1,'LineWidth',2,'Color','r');
h12=line(x2,y2,'LineWidth',2,'Color','r');
h13=line(x3,y3,'LineWidth',2,'Color','r');
h14=line(x4,y4,'LineWidth',2,'Color','r');
while ishandle(hf)
    for j=1:60
    for i=1:60
      x1=;
      y1=;
      x2=;
      y2=;
      h1=line(x1,y1);set(h1,'LineWidth',0.5,'Color','r');
      h2=line(x2,y2);set(h2,'LineWidth',2,'Color','g');
      hm=text(0.5,0,int2str(j-1));
      text(0.7,0,':');
      hs=text(0.8,0,int2str(i-1));
      F=getframe();
      delete(h1);
      delete(h2);
      delete(hm);
      delete(hs);
    end
end
end
movie(F)
运行后,命令窗口出现了下面的东西:
??? Error using ==> capturescreen
Figure destroyed during getframe
Error in ==> getframe at 35
x=capturescreen(varargin{:});
Error in ==> Clock at 38
      F=getframe();
求高人指点,谢谢

messenger 发表于 2010-6-20 00:59:21

getframe应该紧跟在绘图命令后面,仔细看看help中的getframe的例子

荒草 发表于 2010-6-23 20:48:02

貌似已经了解了。我是在该程序还没运行完的时候,就关闭了图形窗口,结果就出现这个问题。
页: [1]
查看完整版本: 求助!Figure destroyed during getframe