- 积分
- 0
- 注册时间
- 2010-6-18
- 仿真币
-
- 最后登录
- 1970-1-1
|
本人初学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=[0 0];x2=[1.7 2];x3=[0 0];x4=[-1.7 -2];
y1=[1.7 2];y2=[0 0];y3=[-1.7 -2];y4=[0 0];
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=[0 1.9*cos(-(i-1)*pi/30+pi/2)];
y1=[0 1.9*sin(-(i-1)*pi/30+pi/2)];
x2=[0 1.5*cos(-(j-1)*pi/30+pi/2)];
y2=[0 1.5*sin(-(j-1)*pi/30+pi/2)];
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();
求高人指点,谢谢 |
|