yuedx的个人空间 https://blog.eetop.cn/317611 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

显示当前时间的表!!(zz)

已有 617 次阅读| 2009-4-22 18:29 |个人分类:matlab基础知识

http://luobo.ycool.com/post.651176.html
% 显示当前时间的表
try
close all
hfig=figure;
set(hfig,'NumberTitle','off');
set(hfig,'name','显示当前时间的表');
set(hfig,'MenuBar','none');

set(hfig,'color',[0.5 0.7 0.3])
A=linspace(0,6.3,1000);
x1=8*cos(A);
y1=8*sin(A);

x2=7*cos(A);
y2=7*sin(A);
plot(x1,y1,'b','linewidth',1.4)
hold on
plot(x2,y2,'b','linewidth',3.5)
fill(0.4*cos(A),0.4*sin(A),'r');
axis off


axis([-10 10 -10 10])
axis equal
set(gca,'position',[[0.13 0.05 0.775 0.815]])
title(date,'fontsize',18)
for k=1:12;
   xk=9*cos(-2*pi/12*k+pi/2);
   yk=9*sin(-2*pi/12*k+pi/2);
   plot([xk/9*8 xk/9*7],[yk/9*8 yk/9*7],'color',[0.3 0.8 0.9])
%     if k
   h=text(xk,yk,num2str(k),'fontsize',16,'color',...
       [0.9 0.3 0.8],'HorizontalAlignment','center');
end
% 计算时针位置
ti=clock;
th=-(ti(4)+ti(5)/60+ti(6)/3600)/12*2*pi+pi/2;
xh3=4.0*cos(th);
yh3=4.0*sin(th);
xh2=xh3/2+0.5*cos(th-pi/2);
yh2=yh3/2+0.5*sin(th-pi/2);
xh4=xh3/2-0.5*cos(th-pi/2);
yh4=yh3/2-0.5*sin(th-pi/2);
hh=fill([0 xh2 xh3 xh4 0],[0 yh2 yh3 yh4 0],[0.6 0.5 0.3]);


% 计算分针位置
tm=-(ti(5)+ti(6)/60)/60*2*pi+pi/2;
xm3=6.0*cos(tm);
ym3=6.0*sin(tm);
xm2=xm3/2+0.5*cos(tm-pi/2);
ym2=ym3/2+0.5*sin(tm-pi/2);
xm4=xm3/2-0.5*cos(tm-pi/2);
ym4=ym3/2-0.5*sin(tm-pi/2);
hm=fill([0 xm2 xm3 xm4 0],[0 ym2 ym3 ym4 0],[0.6 0.5 0.3]);
% 计算秒针位置
ts=-(ti(6))/60*2*pi+pi/2;
hs=plot([0 7*cos(ts)],[0 7*sin(ts)],...
   'color',[0.6 0.5 0.3],'linewidth',3);
set(gcf,'doublebuffer','on');
k=1;
while k<6;
   ti=clock;
   % 计算时针位置
   th=-(ti(4)+ti(5)/60+ti(6)/3600)/12*2*pi+pi/2;
   xh3=4.0*cos(th);
   yh3=4.0*sin(th);
   xh2=xh3/2+0.5*cos(th-pi/2);
   yh2=yh3/2+0.5*sin(th-pi/2);


   xh4=xh3/2-0.5*cos(th-pi/2);
   yh4=yh3/2-0.5*sin(th-pi/2);
   set(hh,'XData',[0 xh2 xh3 xh4 0],'YData',[0 yh2 yh3 yh4 0])

   % 计算分针位置
   tm=-(ti(5)+ti(6)/60)/60*2*pi+pi/2;
   xm3=6.0*cos(tm);
   ym3=6.0*sin(tm);
   xm2=xm3/2+0.5*cos(tm-pi/2);
   ym2=ym3/2+0.5*sin(tm-pi/2);
   xm4=xm3/2-0.5*cos(tm-pi/2);
   ym4=ym3/2-0.5*sin(tm-pi/2);
   set(hm,'XData',[0 xm2 xm3 xm4 0],'YData',[0 ym2 ym3 ym4 0])
   % 计算秒针位置
   ts=-(ti(6))/60*2*pi+pi/2;
   set(hs,'XData',[0 7*cos(ts)],'YData',[0 7*sin(ts)])
   drawnow;
   pause(0.09)
end

catch
end

点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 13

    粉丝
  • 1

    好友
  • 35

    获赞
  • 156

    评论
  • 4698

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-27 05:15 , Processed in 0.010762 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部