zoukankan      html  css  js  c++  java
  • matlab绘制实用日历实例代码


    function TheStudy;%函数名 close all;%关闭所有床头 DD={'Sun','Mon','Tue','Wed','Thu','Fri','Sat'};%日历表头文字 figure;%打开一个窗口 %绘制窗口中的图标 uicontrol(gcf,'style','text','unit','normalized','position',[0.12,0.9,0.4,0.08],... 'ForegroundColor',[0.4,0.9,0.8],'BackgroundColor',[0.3,0.4,0.4],'fontsize',21,'String','The Calendar'); td=uicontrol(gcf,'style','push','unit','normalized',... 'position',[0.22,0.1,0.5,0.1],'fontname','default',... 'fontsize',18,'ForegroundColor',0.6*[1,1,1],'BackgroundColor','r'); %绘制日历的表头 for k=1:7 uicontrol(gcf,'style','text','unit','normalized',... 'position',[0.02+k*0.1,0.7,0.08,0.06],'fontsize',18,... 'ForegroundColor','r','BackgroundColor','b','String',DD{k}); end %取出现在时间的字符串 timestr=datestr(now); %时间付给年 月 日 [y,m,d]=datevec(timestr); %本月的总天数 last=eomday(y,m); %--------- %以下四行为求月初是星期几的算法。 %总结出来的规律 %假设目前为星期 x(1<=x<=7),日期号为d. %得y=x+1+7-rem(d,7); %∴本月初为星期z=rem(y,7)+1; number_week=weekday(timestr); remvalue=rem(d,7); number_week=number_week+7-remvalue; number_week=rem(number_week,7)+1; row=0; total_num=0;%记录画上图标的天数,不超过本月总天数(last) bc='b'; while total_num<last total_num=total_num+1; if total_num==d bc='r'; else bc='w'; end uicontrol(gcf,'style','push','ForegroundColor',bc,'BackgroundColor',0.4*[1,1,1],... 'String',num2str(total_num),'fontsize',18,'fontname','default','unit','normalized',... 'position',[0.02+number_week*0.1,0.6-row*0.08,0.08,0.06]); if number_week==7 row=row+1; number_week=1; else number_week=number_week+1; end end try%循环显示当前时间 while 1 [y,m,d,h,mi,s]=datevec(datestr(now)); set(td,'String',[datestr(now,2),' ',datestr(now,13)]); pause(1); end end

      执行结果:

  • 相关阅读:
    一次友情协助的渗透测试
    jQuery---微博发布案例
    jQuery---清空节点和删除节点
    jQuery---城市选择案例
    jQuery---创建和添加节点
    jQuery---动态创建节点
    jQuery---音乐导航
    jQuery---停止动画详解 stop();
    jQuery---手风琴案例+stop的使用(解决动画队列的问题)
    jQuery---自定义动画 animate();
  • 原文地址:https://www.cnblogs.com/sytu/p/4294481.html
Copyright © 2011-2022 走看看