matlab课程设计简单计算器的设计.docx
- 文档编号:8558446
- 上传时间:2023-01-31
- 格式:DOCX
- 页数:10
- 大小:83.49KB
matlab课程设计简单计算器的设计.docx
《matlab课程设计简单计算器的设计.docx》由会员分享,可在线阅读,更多相关《matlab课程设计简单计算器的设计.docx(10页珍藏版)》请在冰豆网上搜索。
matlab课程设计简单计算器的设计
matlab课程设计报告
题目
简易计算器得设计
学院
电子信息工程学院
专业
电子信息
学生姓名与学号
指导教师
一、选题目得及意义
GUI得广泛应用就是当今计算机发展得重大成就之一,它极大地方便了非专业用户得使用。
人们从此不再需要死记硬背大量得命令,取而代之得就是可以通过窗口、菜单、按键等方式来方便地进行操作,而在matlab有很简单得gui设计工具,我们可以通过这个工具轻松地构建我们想要得程序,从而实现与用户得信息交互。
本次课程设计就是使用了matlab中得guide生成了简单得计算器程序。
二、源代码
functionvarargout=Calculator(varargin)
%SimpleCalculator
%AnhuiUniversity
%BegininitializationcodeDONOTEDIT
gui_Singleton=1;
gui_State=struct('gui_Name',m,、、、
'gui_Singleton',gui_Singleton,、、、
'gui_OpeningFcn',Calculator_OpeningFcn,、、、
'gui_OutputFcn',Calculator_OutputFcn,、、、
'gui_LayoutFcn',[],、、、
'gui_Callback',[]);
ifnargin&&ischar(varargin{1})
gui_State、gui_Callback=str2func(varargin{1});
end
ifnargout
[varargout{1:
nargout}]=gui_mainfcn(gui_State,varargin{:
});
else
gui_mainfcn(gui_State,varargin{:
});
end
%EndinitializationcodeDONOTEDIT
%ExecutesjustbeforeCalculatorismadevisible、
functionCalculator_OpeningFcn(hObject,eventdata,handles,varargin)
%Thisfunctionhasnooutputargs,seeOutputFcn、
%hObjecthandletofigure
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%vararginmandlineargumentstoCalculator(seeVARARGIN)
%ChoosedefaultmandlineoutputforCalculator
handles、output=hObject;
%Updatehandlesstructure
guidata(hObject,handles);
%UIWAITmakesCalculatorwaitforuserresponse(seeUIRESUME)
%uiwait(handles、figure1);
%Outputsfromthisfunctionarereturnedtothemandline、
functionvarargout=Calculator_OutputFcn(hObject,eventdata,handles)
%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);
%hObjecthandletofigure
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Getdefaultmandlineoutputfromhandlesstructure
varargout{1}=handles、output;
%Executesonbuttonpressinp1、
functionp1_Callback(hObject,eventdata,handles)
%hObjecthandletop1(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'1');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp2、
functionp2_Callback(hObject,eventdata,handles)
%hObjecthandletop2(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'2');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp3、
functionp3_Callback(hObject,eventdata,handles)
%hObjecthandletop3(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'3');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp4、
functionp4_Callback(hObject,eventdata,handles)
%hObjecthandletop4(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'4');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp5、
functionp5_Callback(hObject,eventdata,handles)
%hObjecthandletop5(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'5');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp6、
functionp6_Callback(hObject,eventdata,handles)
%hObjecthandletop6(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'6');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp7、
functionp7_Callback(hObject,eventdata,handles)
%hObjecthandletop7(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'7');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp8、
functionp8_Callback(hObject,eventdata,handles)
%hObjecthandletop8(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'8');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp9、
functionp9_Callback(hObject,eventdata,handles)
%hObjecthandletop9(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'9');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinadd、
functionadd_Callback(hObject,eventdata,handles)
%hObjecthandletoadd(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'+');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinp0、
functionp0_Callback(hObject,eventdata,handles)
%hObjecthandletop0(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'0');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinsub、
functionsub_Callback(hObject,eventdata,handles)
%hObjecthandletosub(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'');
set(handles、text1,'string',textstring)
%Executesonbuttonpressindiv、
functiondiv_Callback(hObject,eventdata,handles)
%hObjecthandletodiv(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'/');
set(handles、text1,'string',textstring)
%Executesonbuttonpressinmul、
functionmul_Callback(hObject,eventdata,handles)
%hObjecthandletomul(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'*');
set(handles、text1,'string',textstring)
%Executesonbuttonpressindenghao、
functiondenghao_Callback(hObject,eventdata,handles)
%hObjecthandletodenghao(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=eval(textstring);
set(handles、text1,'string',textstring)
%Executesonbuttonpressinclear、
functionclear_Callback(hObject,eventdata,handles)
%hObjecthandletoclear(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
set(handles、text1,'string','0')
%
functionexit_Callback(hObject,eventdata,handles)
%hObjecthandletoexit(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
close(gcf)
%
functioncalculate_Callback(hObject,eventdata,handles)
%hObjecthandletocalculate(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=eval(textstring);
set(handles、text1,'string',textstring)
%Executesonbuttonpressinpoint、
functionpoint_Callback(hObject,eventdata,handles)
%hObjecthandletopoint(seeGCBO)
%eventdatareservedtobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
textstring=get(handles、text1,'string');
textstring=strcat(textstring,'、');
set(handles、text1,'string',textstring)
设计功能:
1.可进行加减乘除四则运算
2.可进行清零,退出等
三、界面设计及运行结果
11、GUIDE设计界面
12、进入程序初始状态
13、简单得实例测试
五、心得及体会
通过这次matlab课程设计,让我对matlab有了更深得了解。
Matlab不仅给我们更方便得编程体验,其中强大得数值运算,信号处理等功能更就是我们专业实现相关系统设计得好工具。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- matlab 课程设计 简单 计算器 设计