实例:查询日期

[复制链接]
935|0
 楼主| cooldog123pp 发表于 2024-7-26 23:49 | 显示全部楼层 |阅读模式
  1. h0=figure('toolbar','none',...
  2.     'position',[198 56 408 468],...
  3.     'name','实例55');
  4. h1=axes('parent',h0,...
  5.     'position',[0.15 0.5 0.7 0.5],...
  6.     'visible','off');
  7. huidiao=[...
  8.         'yearnum=str2num(get(edit1,''string''));,',...
  9.         'monthnum=str2num(get(edit2,''string''));,',...
  10.         'daynum=str2num(get(edit3,''string''));,',...
  11.         'monthday=[0 31 28 31 30 31 30 31 31 30 31 30 31];,',...
  12.         'dyear=yearnum-2000;,',...
  13.         'beishu=fix(dyear/4);,',...
  14.         'yushu=rem(yearnum,4);,',...
  15.         'if yushu==0,',...
  16.         'monthday(3)=29;,',...
  17.         'end,',...
  18.         'mday=0;,',...
  19.         'for i=1:monthnum,',...
  20.         'mday=monthday(i)+mday;,',...
  21.         'end,',...
  22.         'yearday=mday+daynum-1;,',...
  23.         'noweek=fix(yearday/7);,',...
  24.         'set(edit5,''string'',[''第'',num2str(noweek),''周'']);,',...
  25.         'if dyear>0,',...
  26.         'if yushu==0,',...
  27.         'beishu=beishu-1;,',...
  28.         'end,',...
  29.         'dday=yearday+365*dyear+beishu+1;,',...
  30.         'end,',...
  31.         'if dyear<=0,',...
  32.         'dday=365*dyear+yearday+beishu;,',...
  33.         'end,',...
  34.         'mweek=rem(dday,7)+7;,',...
  35.         'if mweek==8,',...
  36.         'set(edit4,''string'',''Sunday'');,',...
  37.         'end,',...
  38.         'if mweek==9,',...
  39.         'set(edit4,''string'',''Monday'');,',...
  40.         'end,',...
  41.         'if mweek==10,',...
  42.         'set(edit4,''string'',''Tuesday'');,',...
  43.         'end,',...
  44.         'if mweek==11,',...
  45.         'set(edit4,''string'',''Wednesday'');,',...
  46.         'end,',...
  47.         'if mweek==12,',...
  48.         'set(edit4,''string'',''Thursday'');,',...
  49.         'end,',...
  50.         'if mweek==13,',...
  51.         'set(edit4,''string'',''Friday'');,',...
  52.         'end,',...
  53.         'if mweek==7,',...
  54.         'set(edit4,''string'',''Saturday'');,',...
  55.         'end,',...
  56.         'if mweek==6,',...
  57.         'set(edit4,''string'',''Friday'');,',...
  58.         'end,',...
  59.         'if mweek==5,',...
  60.         'set(edit4,''string'',''Thursday'');,',...
  61.         'end,',...
  62.         'if mweek==4,',...
  63.         'set(edit4,''string'',''Wednesday'');,',...
  64.         'end,',...
  65.         'if mweek==3,',...
  66.         'set(edit4,''string'',''Tuesday'');,',...
  67.         'end,',...
  68.         'if mweek==2,',...
  69.         'set(edit4,''string'',''Monday'');,',...
  70.         'end,',...
  71.         'if mweek==1,',...
  72.         'set(edit4,''string'',''Sunday'');,',...
  73.         'end'];
  74. edit1=uicontrol('parent',h0,...
  75.     'style','edit',...
  76.     'horizontalalignment','right',...
  77.     'position',[40 300 50 20]);
  78. text1=uicontrol('parent',h0,...
  79.     'style','text',...
  80.     'string','年',...
  81.     'horizontalalignment','left',...
  82.     'position',[90 300 50 20]);
  83. edit2=uicontrol('parent',h0,...
  84.     'style','edit',...
  85.     'horizontalalignment','right',...
  86.     'position',[160 300 50 20]);
  87. text2=uicontrol('parent',h0,...
  88.     'style','text',...
  89.     'string','月',...
  90.     'horizontalalignment','left',...
  91.     'position',[210 300 50 20]);
  92. edit3=uicontrol('parent',h0,...
  93.     'style','edit',...
  94.     'horizontalalignment','right',...
  95.     'position',[280 300 50 20]);
  96. text3=uicontrol('parent',h0,...
  97.     'style','text',...
  98.     'string','日',...
  99.     'horizontalalignment','left',...
  100.     'position',[330 300 50 20]);
  101. edit4=uicontrol('parent',h0,...
  102.     'style','edit',...
  103.     'horizontalalignment','left',...
  104.     'position',[210 200 120 20]);
  105. text4=uicontrol('parent',h0,...
  106.     'style','text',...
  107.     'string','查找的日期为',...
  108.     'horizontalalignment','right',...
  109.     'position',[110 200 100 20]);
  110. edit5=uicontrol('parent',h0,...
  111.     'style','edit',...
  112.     'horizontalalignment','left',...
  113.     'position',[210 100 120 20]);
  114. text1=uicontrol('parent',h0,...
  115.     'style','text',...
  116.     'string','该日处于',...
  117.     'horizontalalignment','left',...
  118.     'position',[160 100 50 20]);
  119. button1=uicontrol('parent',h0,...
  120.     'style','pushbutton',...
  121.     'position',[80 40 80 30],...
  122.     'string','开始',...
  123.     'callback',huidiao);
  124. button2=uicontrol('parent',h0,...
  125.     'style','pushbutton',...
  126.     'position',[220 40 80 30],...
  127.     'string','关闭',...
  128.     'callback','close');


您需要登录后才可以回帖 登录 | 注册

本版积分规则

2345

主题

7742

帖子

31

粉丝
快速回复 在线客服 返回列表 返回顶部