Matlab的gui界面设计实例练习

上传人:鲁** 文档编号:510811549 上传时间:2022-09-26 格式:DOC 页数:6 大小:108KB
返回 下载 相关 举报
Matlab的gui界面设计实例练习_第1页
第1页 / 共6页
Matlab的gui界面设计实例练习_第2页
第2页 / 共6页
Matlab的gui界面设计实例练习_第3页
第3页 / 共6页
Matlab的gui界面设计实例练习_第4页
第4页 / 共6页
Matlab的gui界面设计实例练习_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《Matlab的gui界面设计实例练习》由会员分享,可在线阅读,更多相关《Matlab的gui界面设计实例练习(6页珍藏版)》请在金锄头文库上搜索。

1、一个不错的 Matlab 的 gui 界面设计实例%非常漂亮的日历,function CalendarTable;% calendar 日历% Example:% CalendarTable;S=datestr(now);y,m,d=datevec(S);% d is day% m is month% y is yearDD=Sun,Mon,Tue,Wed,Thu,Fri,Sat;close allfigure;for k=1:7;uicontrol(gcf,style,text,.unit,normalized,position,0.02+k*0.1,0.55,0.08,0.06,.Back

2、groundColor,0.6*1,1,1,ForegroundColor,b,.String,DD(k),fontsize,16,fontname,times new roman);endh=1;ss=b;qq=eomday(y,m);for k=1:qq;n=datenum(y,m,k);da,w = weekday(n);if k=d;ss=r;enduicontrol(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,Foregro

3、undColor,ss,.String,num2str(k);ss=b;if da=7;h=h+1;endenduic on trol(gcf,style,push,.un it, normalized,positio n ,0.6,0.66,0.12,0.08,.Backgrou ndColor,0.6*1,1,1,Foregrou ndColor,ss,.String,clock,fontsize,18,fontname,times new roman);Tq=uic on trol(gcf,style,push,.un it, normalized,positio n ,0.74,0.6

4、6,0.17,0.08,.Backgrou ndColor,0.6*1,1,1,Foregro un dColor,0.1,0.9,0.9,.fon tsize,18,fo ntn ame,times new roma n);sq=The cale ndar;uic on trol(gcf,style,push,.un it, normalized,positio n ,0.14,0.86,0.37,0.08,.Backgrou ndColor,0.6*1,1,1,Foregro un dColor,0.1,0.9,0.9,.fon tsize,18,fo ntn ame,times new

5、roma n,stri ng,sq);trywhile 1set(Tq,Stri ng,datestr( no w,13);pause(1);endend计算万年历的 Matlab程序(2008-12-21 13:59:佝标签:matlab万年历杂谈分类:Matlab实例function test_cale ndar(year,m on th)%输入年份,月份,打印这个月的月历run = 0;pi ng = 0;fprin tf(n%s %s %s %s %s %s %sn,.日,一,二,三,四,五,六);%计算从第一年到前一年的闰年和平年的个数for i =1:year-1if (mod(i

6、,4)=0 & mod(i,100)=0) | mod(i,400)=0 run = run+1;elseping = ping+1;end end % 计算从第一年到当年前一个月的天数 sum = 366*run+365*ping;for i = 1:month-1sum = sum+monthday(year,i); end% 获得这个月的天数 n = monthday(year,month); temp = zeros(n,1); sum = sum+1;% 计算这个月第一天是星期几 wkd = mod(sum,7);for i = 1:ntemp(wkd+i) = i; end l =

7、 1; m = 1;% 打印日历for i = 1:length(temp)if temp(i) =0 temp2(l,m) = ; fprintf( ); m = m+1;elsetemp2(l,m) = temp(i);if temp(i) = 10fprintf(%d ,temp(i); elsefprintf(%d ,temp(i);endm = m+1;endif mod(i,7)=0 fprintf(n); m = 1;l = l+1;end endfprin tf(n);%闰年和平年每月的天数 function out = mon thday(year,i)if mod(year

8、,4)=0 & mod(year,100)=0 | mod(year,400)=0data = 31 29 31 30 31 30 31 31 30 31 30 31;elsedata = 31 28 31 30 31 30 31 31 30 31 30 31;endout = data(i);举例:输入: test_cale ndar(2008,12)返回:日一二三四五六1 2 3 4 5 67 8 9 10 11 12 1314 15 16 17 18 19 2021 22 23 24 25 26 2728 29 30 31闲来无事,学了一些Matlab GUI的基础知识,想找个东西练一下手。看中了 windows的日期与时间显示面板, 于是依葫芦画瓢,用Matlab做了一个,嘿嘿,觉得还挺像模像样的。 下面是效果图。亠T:曲9当前时区沖国标准时阿Mat labs慕世宁卜I毎irwuonix;M/xignfaT *10今日进一步完成了农历的计算和显示。万年历再闻软料叭-1十T J20(39 -鼠年十1月日B*J1四五1 T0日羁+B10丘亦12719紀26就30“tip */!/“ 0“9日 斗门:心其 tQl*F 迂 1 1 .Q

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号