资源描述:
《Matlab的gui界面设计实例练习.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一个不错的Matlab的gui界面设计实例%非常漂亮的日历,functionCalendarTable;%calendar日历%Example:% CalendarTable;S=datestr(now);[y,m,d]=datevec(S);%disday%mismonth%yisyearDD={'Sun','Mon','Tue','Wed','Thu','Fri','Sat'};closeallfigure;fork=1:7; uicontrol(gcf,'style','text',... 'unit',
2、'normalized','position',[0.02+k*0.1,0.55,0.08,0.06],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor','b',... 'String',DD(k),'fontsize',16,'fontname','timesnewroman');endh=1;ss='b';qq=eomday(y,m);fork=1:qq; n=datenum(y,m,k); [da,w]=weekday(n); ifk==d;
3、 ss='r'; end uicontrol(gcf,'style','push',... 'unit','normalized','position',[0.02+da*0.1,0.55-h*0.08,0.08,0.06],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor',ss,... 'String',num2str(k)); ss='b'; ifda==7; h=h+1; endenduicontrol(gc
4、f,'style','push',... 'unit','normalized','position',[0.6,0.66,0.12,0.08],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor',ss,... 'String','clock','fontsize',18,'fontname','timesnewroman');Tq=uicontrol(gcf,'style','push',... 'unit','normalized','position',[0.7
5、4,0.66,0.17,0.08],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor',[0.1,0.9,0.9],... 'fontsize',18,'fontname','timesnewroman');sq='Thecalendar';uicontrol(gcf,'style','push',... 'unit','normalized','position',[0.14,0.86,0.37,0.08],... 'BackgroundColor',0.6*[1,
6、1,1],'ForegroundColor',[0.1,0.9,0.9],... 'fontsize',18,'fontname','timesnewroman','string',sq);try while1 set(Tq,'String',datestr(now,13)); pause(1); endend计算万年历的Matlab程序(2008-12-2113:59:19)标签:matlab 万年历 杂谈 分类:Matlab实例functiontest_calendar(year,month)%输
7、入年份,月份,打印这个月的月历run=0;ping=0;fprintf('%s%s%s%s%s%s%s',... '日','一','二','三','四','五','六');%计算从第一年到前一年的闰年和平年的个数fori=1:year-1 if(mod(i,4)==0&mod(i,100)~=0)
8、mod(i,400)==0 run=run+1; else ping=ping+1; endend%计算从第一年到当年前一个月的天数sum=366*run+365*ping;fori=
9、1:month-1 sum=sum+monthday(year,i);end%获得这个月的天数n=monthday(year,month);temp=zeros(n,1);sum=sum+1;%计算这个月第一天是星期几wkd=mod(sum,7);fori=1:n t