收藏 分享(赏)

matlab课程设计(简单计算器的设计).doc

上传人:精品资料 文档编号:10506956 上传时间:2019-11-24 格式:DOC 页数:17 大小:86.12KB
下载 相关 举报
matlab课程设计(简单计算器的设计).doc_第1页
第1页 / 共17页
matlab课程设计(简单计算器的设计).doc_第2页
第2页 / 共17页
matlab课程设计(简单计算器的设计).doc_第3页
第3页 / 共17页
matlab课程设计(简单计算器的设计).doc_第4页
第4页 / 共17页
matlab课程设计(简单计算器的设计).doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

1、 1 / 17matlab 课程设计报告题 目 简易计算器的设计学 院 电子信息工程学院专 业 电子信息学生姓名和学号指导教师2 / 173 / 17一 、选题目的及意义GUI 的广泛应用是当今计算机发展的重大成就之一,它极大地方便了非专业用户的使用。人们从此不再需要死记硬背大量的命令,取而代之的是可以通过窗口、菜单、按键等方式来方便地进行操作,而在 matlab 有很简单的 gui 设计工具,我们可以通过这个工具轻松地构建我们想要的程序,从而实现与用户的信息交互。本次课程设计是使用了 matlab 中的 guide 生成了简单的计算器程序。二、源代码function varargout =

2、Calculator(varargin)%Simple Calculator%Anhui University% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, .gui_Singleton, gui_Singleton, .gui_OpeningFcn, Calculator_OpeningFcn, .gui_OutputFcn, Calculator_OutputFcn, .4 / 17gui_LayoutFcn, , .gui_Callback

3、, );if nargin endif nargoutvarargout1:nargout = gui_mainfcn(gui_State, varargin:);elsegui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before Calculator is made visible.function Calculator_OpeningFcn(hObject, eventdata, handles, varargin)% This function h

4、as 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 arguments to Calculator (see VARARGIN)% Choose default command line output for Calculatorha

5、ndles.output = hObject;5 / 17% Update handles structureguidata(hObject, handles);% UIWAIT makes Calculator wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = Calculator_OutputFcn(hObject, eventdata, hand

6、les) % 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 structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.o

7、utput;% - Executes on button press in p1.function p1_Callback(hObject, eventdata, handles)% hObject handle to p1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=str

8、cat(textstring,1);6 / 17set(handles.text1,string,textstring)% - Executes on button press in p2.function p2_Callback(hObject, eventdata, handles)% hObject handle to p2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDA

9、TA)textstring=get(handles.text1,string);textstring=strcat(textstring,2);set(handles.text1,string,textstring)% - Executes on button press in p3.function p3_Callback(hObject, eventdata, handles)% hObject handle to p3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles

10、 structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,3);set(handles.text1,string,textstring)% - Executes on button press in p4.function p4_Callback(hObject, eventdata, handles)% hObject handle to p4 (see GCBO)% eventdata reserved - to b

11、e defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)7 / 17textstring=get(handles.text1,string);textstring=strcat(textstring,4);set(handles.text1,string,textstring)% - Executes on button press in p5.function p5_Callback(hObject, eventdata, handles)% hObj

12、ect handle to p5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,5);set(handles.text1,string,textstring)% - Executes on button press in p6.functio

13、n p6_Callback(hObject, eventdata, handles)% hObject handle to p6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,6);set(handles.text1,string,texts

14、tring)% - Executes on button press in p7.function p7_Callback(hObject, eventdata, handles)% hObject handle to p7 (see GCBO)8 / 17% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstri

15、ng=strcat(textstring,7);set(handles.text1,string,textstring)% - Executes on button press in p8.function p8_Callback(hObject, eventdata, handles)% hObject handle to p8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDA

16、TA)textstring=get(handles.text1,string);textstring=strcat(textstring,8);set(handles.text1,string,textstring)% - Executes on button press in p9.function p9_Callback(hObject, eventdata, handles)% hObject handle to p9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles

17、 structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,9);set(handles.text1,string,textstring)% - Executes on button press in add.9 / 17function add_Callback(hObject, eventdata, handles)% hObject handle to add (see GCBO)% eventdata reserv

18、ed - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,+);set(handles.text1,string,textstring)% - Executes on button press in p0.function p0_Callback(hObject, eventdata, handles)% h

19、Object handle to p0 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,0);set(handles.text1,string,textstring)% - Executes on button press in sub.fun

20、ction sub_Callback(hObject, eventdata, handles)% hObject handle to sub (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,-);10 / 17set(handles.text1

21、,string,textstring)% - Executes on button press in div.function div_Callback(hObject, eventdata, handles)% hObject handle to div (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string

22、);textstring=strcat(textstring,/);set(handles.text1,string,textstring)% - Executes on button press in mul.function mul_Callback(hObject, eventdata, handles)% hObject handle to mul (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user da

23、ta (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,*);set(handles.text1,string,textstring)% - Executes on button press in denghao.11 / 17function denghao_Callback(hObject, eventdata, handles)% hObject handle to denghao (see GCBO)% eventdata reserved - to be defined in

24、a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=eval(textstring);set(handles.text1,string,textstring)% - Executes on button press in clear.function clear_Callback(hObject, eventdata, handles)% hObject handle to cle

25、ar (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.text1,string,0)% -function exit_Callback(hObject, eventdata, handles)% hObject handle to exit (see GCBO)% eventdata reserved - to be defined in a fut

26、ure version of MATLAB% handles structure with handles and user data (see GUIDATA)12 / 17close(gcf)% -function calculate_Callback(hObject, eventdata, handles)% hObject handle to calculate (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and

27、user data (see GUIDATA)textstring=get(handles.text1,string);textstring=eval(textstring);set(handles.text1,string,textstring)% - Executes on button press in point.function point_Callback(hObject, eventdata, handles)% hObject handle to point (see GCBO)% eventdata reserved - to be defined in a future v

28、ersion of MATLAB% handles structure with handles and user data (see GUIDATA)textstring=get(handles.text1,string);textstring=strcat(textstring,.);set(handles.text1,string,textstring)设计功能:13 / 171.可进行加减乘除四则运算2.可进行清零,退出等三、界面设计及运行结果14 / 171-1. GUIDE 设计界面15 / 171-2.进入程序初始状态16 / 171-3.简单的实例测试17 / 17五、心得及体会通过这次 matlab 课程设计,让我对 matlab 有了更深的了解。Matlab 不仅给我们更方便的编程体验,其中强大的数值运算,信号处理等功能更是我们专业实现相关系统设计的好工具。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报