ImageVerifierCode 换一换
格式:DOC , 页数:40 ,大小:642.50KB ,
资源ID:3791627      下载积分:12 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/3791627.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(用-MATLAB设计一个万年历复习课程.doc)为本站上传会员【w****g】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

用-MATLAB设计一个万年历复习课程.doc

1、 用 MATLAB设计一个万年历 精品资料 课程论文 用 MATLAB设计一个万年历 课 程 数学软件 学生姓名 学 号 手机号码 所在学院 理学院 所在班级 信计1134 任课教师 提交时间 2015年 06 月 07日 目录 万年历的效果图………………………………………………………………………………………………………………………2 第一章 设计目的与要求..........................................

2、3 1.1 设计目的……………………………….………………………………………………………………………………………….3 1.2 设计要求…………………………………………………………………………………………………………………………..3 第二章 GUI界面设计……………………………………………………………………………………………………………3 2.1 打开GUI …………………………………………………………………………………………………………………………..

3、3 2.2 添加按钮控件…………………………………………………………………………………………………………………...4 2.3 根据控件的属性及视觉效果做一定的修改……………………………………………………………………..5 2.4 保存、添加功能函数………………………………………………………………………………………………………..5 2.4.1 在“nian_edit1_Callback”中编写代码………………………………………………………………….5 2.4.2 在“yue_edit2_Callback”中编写代码…………………………………………………………………..6 2.4.

4、3 在“zhou_pushbutton1_Callback”中编写代码…………………………………………………….6 2.4.4 在“rili_pushbutton2_Callback”中编写代码………………………………………………………..6 第三章 万年历的使用…………………………………………………………………………………………………………..7 3.1 运行…………………………………………………………………………………………………………………………………..8 3.2 输入…………………………………………………………………………………………………………………………………..8

5、3.3 错误警告…………………………………………………………………………………………………………………………..9 第四章 改写界面………………….………………………………………………………………………………………………10 第五章 结论、问题解决及改进...............................................................................................10 5.1结论与讨论………………………………………………………………………………………………………………………..10 5.2问题解决…………

6、…………………………………………………………………………………………………………………10 5.3可以加以改进的地方…………………………………………………………………………………………………………10 第六章 心得体会…………………………………………………………………………………………………………………..11 参考文献…………………………………………………………………………………………………………………………………..11 附录:源程序代码……………………………………………………………………………………………………………………11

7、 万年历效果图 第一章 设计目的与要求: 1.1设计目的: 通过万年历程序的设计,培养学生综合利用MATLAB进行程序设计的能力,加强函数的运用,提高软件系统分析能力和程序文档建立、归纳总结的能力,培养学生利用系统提供的标准函数及典型算法进行设计,开发应用软件。      通过本项课程设计,可以培养独立思考、 综合运用所学有关相应知识的能力,能更好的巩固《数学软件》课程学习的内容,掌握 GUI界面设计的基本方法,更加了解了MATLAB的好处和其可用性!  1.2设计要求: 设计一个万年历GUI界面,其界面布局如上图,包括“输入年份”、“输入月份”

8、显示星期”、 “显示日历”等控件。在界面上任意输入某个具体年份和月份,单击按钮即可显示本月的日历及其对应的星期(0表示没有数字日期)。 第二章 GUI界面设计: 2.1打开GUI 输入Guide回车或者在工具栏上点击图标打开Guide窗口: 2.2添加按钮控件 1、选取5个静态文本控件,用来定义“输入年份”、“输入月份”、“星期”、“当月日历显示区”,以及显示每周的“日”、“一”、“二”、“三”、“四”、“五”、“六”; 2、选取两个push button按钮空间用来定义“显示星期”、“显示日历”; 3、添加两个编辑文本框控件用来输入具体的数字年份和月

9、份; 4、添加42个编辑文本框控件,用来显示具体的日期。(具体摆放如下图) 2.3 根据控件的属性及视觉效果做一定的修改 1、双击“输入年份”、“输入月份”、“星期”和“当月日历显示区”这4个静态文本框,在“String”文本框中输入相应的中文,将字体大小“FontSize”设置为20,其他默认即可。 2、对于“星期”下方的静态文本框,“String”文本框中不输入任何内容,将字体大小“FontSize”设置为25,在“Tag”文本框中输入“xingqi_text4”。 3、对于输入年份和月份的编辑文本框,在“String”文本框中输入0,将字体大小“FontSize”设置为

10、18,在“Tag”文本框中分别输入“nian_edit1”和“yue_edit2”。 4、对于两个push button按钮,在“String”文本框中分别输入“显示星期”和“显示日期”,将字体大小“FontSize”都设置为20,在“Tag”文本框中分别输入“zhou_pushbutton1”和“rili_pushbutton2”。 5、对于42个编辑文本框,首先将“Enable”属性中的“on”设置为“inactive”,使其转为静态文本框,并且保持控件的高亮状态;其次,在“String”文本框中都不输入任何内容;最后在“Tag”文本框中从左到右、按列依次输入“r1_edit”、“r2

11、edit”、···、“r42_edit”。 2.4保存、添加功能函数 把做好的按钮及静态文本框保存为“wannianli.fig”后自动弹出Editor的M文本,然后对相应的控件添加功能函数。以下是相应控件的功能函数的代码。(单击工具栏中的按钮可快速跳转到各个控件的回调函数) 2.4.1在“nian_edit1_Callback”中编写代码 function nian_edit1_Callback(hObject, eventdata, handles) % 添加如下程序: input=str2num(get(hObject,'String')); % 输入年份

12、 if(isempty(input)) set(hObject,'String','0') end guidata(hObject,handles); 2.4.2在“yue_edit2_Callback”中编写代码 function yue_edit2_Callback(hObject, eventdata, handles) input=str2num(get(hObject,'String')); % 输入月份 if(isempty(input)) set(hObject,'String','0') end if input>=13

13、 errordlg('月份不能超过12','警告') % 显示警告信息库 end guidata(hObject,handles); 2.4.3在“zhou_pushbutton1_Callback”中编写代码 function zhou_pushbutton1_Callback(hObject, eventdata, handles) % 添加如下程序: h={'日';'一';'二';'三';'四';'五';'六'}; % 显示结果 set(handles.xingqi_text4,'String',h); % 更新结构体 guidata(hObject,ha

14、ndles); 2.4.4在“rili_pushbutton2_Callback”中编写代码 function rili_pushbutton2_Callback(hObject, eventdata, handles) % 添加如下程序: nian=get(handles.nian_edit1,'String'); yue=get(handles.yue_edit2,'String'); year=str2num(nian); month=str2num(yue); %找出各年12个月的天数 for m=1:12 if mod(year,4)==0&mod

15、year,100)~=0|mod(year,400)==0 D=[31 29 31 30 31 30 31 31 30 31 30 31]; else D=[31 28 31 30 31 30 31 31 30 31 30 31]; end Y=D(1:m); end %定义初始值 run=0; %闰年初始值 ping=0; %平年初始值 %计算从第一年到前一年的闰年和平年的个数 for q=1:year-1 if(mod(q,4)==0&mod(q,100)~=0)|mod(q,4

16、00)==0 run=run+1; else ping=ping+1; end end %计算从第一年到当年前一个月的天数 S=366*run+365*ping; for p=1:month-1 S=S+Y(p); end %获得这个月的天数 n=Y(month); A=zeros(n,1); S=S+1; %计算这个月的第一天是星期几 w=mod(S,7); for k=1:n A(w+k)=k; end T=[A(1:end);zeros(42-length(A),1)]; %没有日期

17、用0代替 set(handles.r1_edit,'String',num2str(T(1))); %显示结果 set(handles.r2_edit,'String',num2str(T(2))); set(handles.r3_edit,'String',num2str(T(3))); %以下类推,直到r40_edit(在此省略,但在M文件上必须全部写上) %_________________________________________________ set(handles.r41_edit,'String',num2str(T(4))); set(handles.r4

18、2_edit,'String',num2str(T(5))); guidata(hObject,handles); 第三章 万年历的使用 3.1运行 单击本M文件编辑窗口中工具栏中的“运行”按钮,或单击GUIDE的输出编辑器中的工具栏中的按钮,创建功能GUI界面,如下图 3.2输入 在图中输入年份为“2015”,输入月份为“2”,单击“显示星期”按钮和“显示日历”按钮,显示结果如下图 3.3错误警告 若在“输入月份”文本框中输入的数字超过12,则会弹出警告对话框提示错误。例如输入月份“13”,则弹出如下图所示警告窗口。 第四章 改写界面 注

19、意到上图左上角名称为“万年历”而不是“wannianli”,其实修改很简单,只需在输出编辑器界面中,单击鼠标右键,从弹出的快捷菜单中选择“Property Inspector”命令,打开界面属性窗口。将窗口的标题(Name属性)设置为“万年历”,关闭该窗口,并运行界面,显示结果就是创建的“万年历”窗口。 在图中输入年份为“2015”,输入月份为“6”,单击“显示星期”按钮和“显示日历”按钮,显示结果就是所要创建的GUI界面。 第五章 结论、问题解决与改进 5.1结论与讨论: 经过多次实验,本程序进行本月日历的显示及对应的星期的结果符合事实。 5.2问题解决: 如出现界面数

20、字混乱,可能是因为42个文本框没有从上到下依次添加,可以交换编辑文本框位置,直到显示的日历符合事实为止。 5.3可以加以改进的地方: 1.可对GUI界面进行适当美化 2.可增加农历 3.加如节日和农历节气的显示 第六章 心得体会 目前流行的计算机日历程序,比较典型的是Windows各版本中的日历程序以及基础于该程序所开发的各种应用程序中的日历程序。然而,这些程序都千篇一律的局限在一个很短的时间范围内。(Windows各个版本一般都局限在1980年至2099年这一范围内),但是,在很多情况下,特别是在众多的科学研究领域中,一个时间跨度较大的日历程序是很有参考价值的。  经过一个

21、学期对数学软件的学习,我们学习了理论知识,了解了MATLAB这个软件,这些知识都为我们的下一步学习打下了坚实的基础。通过课程设计,一方面是为了检查我们一个学期来我们学习的成果,另一方面也是为了让我们进一步的掌握和运用它,同时也让我们认清自己的不足之处和薄弱环节,加以弥补和加强。  通过本次的MATLAB设计,让我对MATLAB尤其是GUI可视化图形界面的设计功能有了进一步的了解,认识到其功能的强大和丰富的内置函数及工具箱。在MATLAB万年历的设计中,了解关于MATLAB图形用户界面的部分空间的使用方法,利用MATLAB的GUI提供的很多实用控件,方便用于设计自己的图形界面。 在万年历的编

22、写过程中也体会到了做事情一顶要细心、认真。更加知道了要掌握好基础知识。还有体会到了成功的感觉!通过本项课程设计也培养了我独立思考、 综合运用所学有关相应知识的能力。 参考文献 【1】杨德平、赵维加、管殿柱.MATLAB基础教程.机械工业出版社.2014.11 【2】施晓红、周佳.精通GUI图形界面教程[M].北京:北京理工大学出版社.2003. 【3】罗华飞.MATLAB GUI设计学习手记[M].北京:北京航空航天大学出版社.2009.8.1  附录:程序源代码 function varargout = wannianli(varargin) % WANNIAN

23、LI MATLAB code for wannianli.fig % WANNIANLI, by itself, creates a new WANNIANLI or raises the existing % singleton*. % % H = WANNIANLI returns the handle to a new WANNIANLI or the handle to % the existing singleton*. % % WANNIANLI('CALLBACK',hObject,eventData,handles

24、) calls the local % function named CALLBACK in WANNIANLI.M with the given input arguments. % % WANNIANLI('Property','Value',...) creates a new WANNIANLI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before wan

25、nianli_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to wannianli_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (single

26、ton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help wannianli % Last Modified by GUIDE v2.5 17-May-2015 21:12:01 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ...

27、 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @wannianli_OpeningFcn, ... 'gui_OutputFcn', @wannianli_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui

28、State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before wannianli is made visible. function wannianl

29、i_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line argu

30、ments to wannianli (see VARARGIN) % Choose default command line output for wannianli handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes wannianli wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this func

31、tion are returned to the command line. function varargout = wannianli_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structu

32、re with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function nian_edit1_Callback(hObject, eventdata, handles) % hObject handle to nian_edit1 (see GCBO) % eventdata reserved - to be defined in a future versio

33、n of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of nian_edit1 as text % str2double(get(hObject,'String')) returns contents of nian_edit1 as a double input=str2num(get(hObject,'String')); if(isempty(input))

34、 set(hObject,'String','0') end guidata(hObject,handles); % --- Executes during object creation, after setting all properties. function nian_edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to nian_edit1 (see GCBO) % eventdata reserved - to be defined in a future version of M

35、ATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'Backg

36、roundColor','white'); end % --- Executes on button press in zhou_pushbutton1. function zhou_pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to zhou_pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with han

37、dles and user data (see GUIDATA) h={'日';'一';'二';'三';'四';'五';'六'}; set(handles.xingqi_text4,'String',h); guidata(hObject,handles); function r1_edit_Callback(hObject, eventdata, handles) % hObject handle to r1_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB

38、 % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of r1_edit as text % str2double(get(hObject,'String')) returns contents of r1_edit as a double % --- Executes during object creation, after setting all properties. functio

39、n r1_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to r1_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Win

40、dows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function r2_edit_Callback(hObject, eventdata, handles) % hObject handle to r2_edit (see GCBO) % eventdata r

41、eserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of r2_edit as text % str2double(get(hObject,'String')) returns contents of r2_edit as a double % --- Executes during ob

42、ject creation, after setting all properties. function r2_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to r2_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint:

43、 edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function r3_edit_Callback(hObject, eventdata, handles) % hObj

44、ect handle to r3_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of r3_edit as text % str2double(get(hObject,'String')) returns contents

45、 of r3_edit as a double % --- Executes during object creation, after setting all properties. function r3_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to r3_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not c

46、reated until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function r4

47、edit_Callback(hObject, eventdata, handles) % hObject handle to r4_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of r4_edit as text %

48、 str2double(get(hObject,'String')) returns contents of r4_edit as a double % --- Executes during object creation, after setting all properties. function r4_edit_CreateFcn(hObject, eventdata, handles) % hObject handle to r4_edit (see GCBO) % eventdata reserved - to be defined in a future ve

49、rsion of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObj

50、ect,'BackgroundColor','white'); end function r5_edit_Callback(hObject, eventdata, handles) % hObject handle to r5_edit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Str

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服