资源描述:
《matlab课程设计汇本(简单计算器的设计).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、matlab课程设计报告题目简易计算器的设计学院电子信息工程学院专业电子信息学生和学号指导教师一、选题目的及意义GUI的广泛应用是当今计算机发展的重大成就之一,它极方便了非专业用户的使用。人们从此不再需要死记硬背大量的命令,取而代之的是可以通过窗口、菜单、按键等方式来方便地进行操作,而在matlab有很简单的gui设计工具,我们可以通过这个工具轻松地构建我们想要的程序,从而实现与用户的信息交互。本次课程设计是使用了matlab中的guide生成了简单的计算器程序。二、源代码functionvarargout=Calcula
2、tor(varargin)%SimpleCalculator%AnhuiUniversity%Begininitializationcode-DONOTEDITgui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',Calculator_OpeningFcn,...'gui_OutputFcn',Calculator_OutputFcn,...'gui_LayoutF
3、cn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});end%Endinitializationcode-DONOTEDIT%---Executesjustb
4、eforeCalculatorismadevisible.functionCalculator_OpeningFcn(hObject,eventdata,handles,varargin)%Thisfunctionhasnooutputargs,seeOutputFcn.%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%
5、varargincommandlineargumentstoCalculator(seeVARARGIN)%ChoosedefaultcommandlineoutputforCalculatorhandles.output=hObject;%Updatehandlesstructureguidata(hObject,handles);%UIWAITmakesCalculatorwaitforuserresponse(seeUIRESUME)%uiwait(handles.figure1);%---Outputsfromth
6、isfunctionarereturnedtothecommandline.functionvarargout=Calculator_OutputFcn(hObject,eventdata,handles)%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesa
7、nduserdata(seeGUIDATA)%Getdefaultcommandlineoutputfromhandlesstructurevarargout{1}=handles.output;%---Executesonbuttonpressinp1.functionp1_Callback(hObject,eventdata,handles)%hObjecthandletop1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handless
8、tructurewithhandlesanduserdata(seeGUIDATA)textstring=get(handles.text1,'string');textstring=strcat(textstring,'1');set(handles.text1,'string',textstring