matlab计算时间差多少秒,Matlab 设计时间计算器 计算时间差

h0=figure('toolbar','none',...

'position',[200 150 300 250],...

'name','时间计算器');

huidiao=[...

'k=0;,',...

'fyear=str2num(get(e1,''string''));,',...

'fmonth=str2num(get(e2,''string''));,',...

'fday=str2num(get(e3,''string''));,',...

'syear=str2num(get(e4,''string''));,',...

'smonth=str2num(get(e5,''string''));,',...

'sday=str2num(get(e6,''string''));,',...

'month=[0 31 28 31 30 31 30 31 31 30 31 30 31];,',...

'k=fix(fyear/4);,',...

'if rem(fyear,4)==0,',...

'month(3)=29;,',...

'else,',...

'k=k+1;,',...

'month(3)=28;,',...

'end,',...

'sum=0;,',...

'for i=1:fmonth,',...

'sum=sum+month(i);,',...

'end,',...

'fdday=fyear*365+sum+fday+k;,',...

'l=fix(syear/4);,',...

'if rem(syear,4)==0,',...

'month(3)=29;,',...

'else,',...

'l=l+1;,',...

'month(3)=28;,',...

'end,',...

'ssum=0;,',...

'for i=1:smonth,',...

'ssum=ssum+month(i);,',...

'end,',...

'sdday=syear*365+ssum+sday+l;,',...

'dday=abs(fdday-sdday);,',...

'set(e7,''string'',[num2str(dday),''天'']);'];

t0=uicontrol('parent',h0,...

'units','points',...

'tag','t0',...

'style','text',...

'string','开始日期:',...

'horizontalalignment','right',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[10 160 80 20]);

t8=uicontrol('parent',h0,...

'units','points',...

'tag','t8',...

'style','text',...

'string','结束日期:',...

'horizontalalignment','right',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[115 160 80 20]);

e1=uicontrol('parent',h0,...

'units','points',...

'tag','e1',...

'style','edit',...

'horizontalalignment','right',...

'backgroundcolor',[1 1 1],...

'position',[20 130 50 20]);

t1=uicontrol('parent',h0,...

'units','points',...

'tag','t1',...

'style','text',...

'string','年',...

'horizontalalignment','left',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[75 130 20 20]);

e2=uicontrol('parent',h0,...

'units','points',...

'tag','e2',...

'style','edit',...

'horizontalalignment','right',...

'backgroundcolor',[1 1 1],...

'position',[20 100 50 20]);

t2=uicontrol('parent',h0,...

'units','points',...

'tag','t2',...

'style','text',...

'string','月',...

'horizontalalignment','left',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[75 100 20 20]);

e3=uicontrol('parent',h0,...

'units','points',...

'tag','e3',...

'style','edit',...

'horizontalalignment','right',...

'backgroundcolor',[1 1 1],...

'position',[20 70 50 20]);

t3=uicontrol('parent',h0,...

'units','points',...

'tag','t3',...

'style','text',...

'string','日',...

'horizontalalignment','left',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[75 70 20 20]);

e4=uicontrol('parent',h0,...

'units','points',...

'tag','e4',...

'style','edit',...

'horizontalalignment','right',...

'backgroundcolor',[1 1 1],...

'position',[120 130 50 20]);

t4=uicontrol('parent',h0,...

'units','points',...

'tag','t4',...

'style','text',...

'string','年',...

'horizontalalignment','left',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[175 130 20 20]);

e5=uicontrol('parent',h0,...

'units','points',...

'tag','e5',...

'style','edit',...

'horizontalalignment','right',...

'backgroundcolor',[1 1 1],...

'position',[120 100 50 20]);

t5=uicontrol('parent',h0,...

'units','points',...

'tag','t5',...

'style','text',...

'string','月',...

'horizontalalignment','left',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[175 100 20 20]);

e6=uicontrol('parent',h0,...

'units','points',...

'tag','e6',...

'style','edit',...

'horizontalalignment','right',...

'backgroundcolor',[1 1 1],...

'position',[120 70 50 20]);

t6=uicontrol('parent',h0,...

'units','points',...

'tag','t6',...

'style','text',...

'string','日',...

'horizontalalignment','left',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[175 70 20 20]);

b1=uicontrol('parent',h0,...

'units','points',...

'tag','b1',...

'style','pushbutton',...

'string','计算日期',...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[20 40 50 20],...

'callback',huidiao);

b2=uicontrol('parent',h0,...

'units','points',...

'tag','b2',...

'style','pushbutton',...

'string','关闭',...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[20 10 50 20],...

'callback','close');

e7=uicontrol('parent',h0,...

'units','points',...

'tag','e7',...

'style','edit',...

'horizontalalignment','right',...

'backgroundcolor',[1 1 1],...

'position',[120 10 80 20]);

t7=uicontrol('parent',h0,...

'units','points',...

'tag','t7',...

'style','text',...

'string','两个日期相差:',...

'horizontalalignment','right',...

'fontsize',15,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[100 30 110 20]);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值