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

加入VIP,免费下载
 

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

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

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(matlabGUI设计简易科学计算器.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

matlabGUI设计简易科学计算器.docx

1、matlabGUI设计简易科学计算器MATLAB大作业班级:姓名:学号:计算器题目本题目通过MATLAB的gui程序设计较为简单,在gui设计中主要用到三种控件,文本编辑框(edit text),静态文本框(Static text),命令按钮(push button)。然后在通过各个按钮的回调函数,实现简单的计算功能。1、功能介绍(1)具有友好的用户图形界面。实现十进制数的加、减、乘、除、乘方、开方等简单计算。(2)具有科学计算函数,包括(反)正弦、(反)余弦、(反)正切、(反)余切、开方、指数等函数运行。(注:三角函数计算的是弧度而不是角度)。(3)有清除键,能清除操作。2、功能实现程序由两

2、个部分组成:MATLAB代码(.m文件)和GUI图形(.fig)。程序使用的流程:直接利用图形界面中的按键键入所需数值、运算符等即可得出结果。备注:软件版本:MATLAB 2011b首先用MATLAB GUI功能,在绘制一个静态文本框和一个文本编辑框,以及33个命令按钮,调整好各控件大小、颜色,整体布局如图所示:(附录中有相关属性修改介绍)然后通过双击各个按钮来改写其属性,在m文件中编写其回调函数,最后在运行调试。2.1 各功能界面设计GUI设计界面:注:底部边框用(Panel)工具添加,有两种设计顺序。(1、先加底部边框,再在底部边框上画功能键。2、先画功能键,布好局,画底框,全选功能键拖动

3、到底框上。)2.2 各功能模块实现(可根据需要增减功能键)算法设计:1. 数字键设计:09以及小数点函数都一样,只是参数不同:例如:按键1响应:global jjtextString = get(handles.text1,String);if(strcmp(textString,0.)=1)&(jj=0) set(handles.text1,String,1) ;elsetextString =strcat(textString,1);set(handles.text1,String,textString)endjj=0;2. 四则运算函数:+功能响应:textString = get(ha

4、ndles.text1,String);textString =strcat(textString,+);set(handles.text1,String,textString)-功能响应:textString = get(handles.text1,String);textString =strcat(textString,-);set(handles.text1,String,textString)功能响应:textString = get(handles.text1,String);textString =strcat(textString,*);set(handles.text1,St

5、ring,textString)功能响应:textString = get(handles.text1,String);textString =strcat(textString,/);set(handles.text1,String,textString)3. 科学计算函数:例如:sin功能响应:textString = get(handles.text1,String);if(strcmp(textString,0.)=1)set(handles.text1,String,0.) ;elsea = strread(textString, %f);a=sin(a);set(handles.t

6、ext1,String,a)end4. 退格键(DEL):通过取屏幕值,计算出其字符长度,然后取其前N-1项的值来实现退格:global jjtextString = get(handles.text1,String);if(strcmp(textString,0.)=1)&(jj=0)set(handles.text1,String,0.) ;elsess=char(textString);l=length(textString);textString=ss(1:l-1);set(handles.text1,String,textString)endjj=0;5. 清屏键函数(AC):set

7、(handles.text1,String,0.) ;2.3 各模块程序添加方法选中一个需添加程序的功能键,右击,View Callbacks,Callback,出现如下图所示界面。(红色框中为所需添加的程序)其他功能键添加方法类似。2.4 各模块实现结果(1)数字键:(2)四则运算函数:(3)科学计算函数:Cos0的计算结果:arctan2的计算结果:经过计算,这些结果均与实际结果相吻合,计算器的功能实现的较为完好。3、程序总结:(1)小数点可以连续输入。解决方法是:用strfind函数查看文本框里有几个小数点,如果已经有一个了,再按小数点就保持不变。(2)按过运算符号后一个数不等于一个数,

8、比如:输入1,按等号,会出来一个3,经过长时间分析得知,这是由于在按运算符号时,系统记录了文本框里的数但没有清空,才会出现这种问题。解决方法是再申请一个不同于加减乘除的另一个符号,并将按过运算符后记录的数值置0。4、心得体会:通过本次的MATLAB课程设计,让我对MATLAB尤其是其GUI设计的功能有了进一步的了解,认识到了它功能的强大。在MATLAB简单计算器的设计中,了解了关于MATLAB图形用户界面的部分控件的使用方法;利用MATLAB的GUI提供的很多实用的控件,方便用于设计属于自己的图形界面和自己所需要实现的功能。5、附录:(1)功能块属性修改表(双击功能块可进入)(2)主要程序fu

9、nction varargout = untitled(varargin)%UNTITLED M- untitled.fig% UNTITLED, by itself, creates a new UNTITLED or raises the existing% singleton*.% H = UNTITLED returns the handle to a new UNTITLED or the handle to% the existing singleton*.% UNTITLED(Property,Value,.) creates a new UNTITLED using the%

10、given property value pairs. Unrecognized properties are passed via% varargin to untitled_OpeningFcn. This calling syntax produces a% warning when there is an existing singleton*.% UNTITLED(CALLBACK) and UNTITLED(CALLBACK,hObject,.) call the% local function named CALLBACK in UNTITLED.M with the given

11、 input% arguments.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help untitled % Last Modified by GUIDE v2.5 19-Dec-2013 11:25:45 % Begin initialization code - DO

12、NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, m, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, untitled_OpeningFcn, . gui_OutputFcn, untitled_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargo

13、ut1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT % - Executes just before untitled is made visible.function untitled_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% h

14、Object handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin unrecognized PropertyName/PropertyValue pairs from the% command line (see VARARGIN) % Choose default command line output for untitledhandles

15、.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes untitled wait for user response (see UIRESUME)% uiwait(handles.figure1);global jj ;set(handles.text1,String,0.);jj=0; % - Outputs from this function are returned to the command line.function varargout = untitled_O

16、utputFcn(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 structure with handles and user data (see GUIDATA) % Get default command line output from handle

17、s structurevarargout1 = handles.output; % - Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (se

18、e GUIDATA)global jjtextString = get(handles.text1,String); if(strcmp(textString,0.)=1)&(jj=0) set(handles.text1,String,1) ;elsetextString =strcat(textString,1);set(handles.text1,String,textString) endjj=0; % - Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata,

19、handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global jjtextString = get(handles.text1,String); if(strcmp(textString,0.)=1)&(jj=0) set(handles.text1,String,2) ;elsetextStr

20、ing =strcat(textString,2);set(handles.text1,String,textString) endjj=0; % - Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structur

21、e with handles and user data (see GUIDATA)global jjtextString = get(handles.text1,String); if(strcmp(textString,0.)=1)&(jj=0) set(handles.text1,String,3) ;elsetextString =strcat(textString,3);set(handles.text1,String,textString) endjj=0; % - Executes on button press in pushbutton4.function pushbutto

22、n4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global jjtextString = get(handles.text1,String); if(strcmp(textString,0.)=1)&(jj=0) set(hand

23、les.text1,String,4) ;elsetextString =strcat(textString,4);set(handles.text1,String,textString) endjj=0; % - Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future ver

24、sion of MATLAB% handles structure with handles and user data (see GUIDATA)global jjtextString = get(handles.text1,String); if(strcmp(textString,0.)=1)&(jj=0) set(handles.text1,String,5) ;elsetextString =strcat(textString,5);set(handles.text1,String,textString) endjj=0; % - Executes on button press i

25、n pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global jjtextString = get(handles.text1,String); if(strcmp(t

26、extString,0.)=1)&(jj=0) set(handles.text1,String,6) ;elsetextString =strcat(textString,6);set(handles.text1,String,textString) endjj=0; % - Executes on button press in pushbutton7.function pushbutton7_Callback(hObject, eventdata, handles)% hObject handle to pushbutton7 (see GCBO)% eventdata reserved

27、 - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global jjtextString = get(handles.text1,String); if(strcmp(textString,0.)=1)&(jj=0) set(handles.text1,String,7) ;elsetextString =strcat(textString,7);set(handles.text1,String,textString) endjj=0

28、; % - Executes on button press in pushbutton8.function pushbutton8_Callback(hObject, eventdata, handles)% hObject handle to pushbutton8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global jjtextString = get(ha

29、ndles.text1,String); if(strcmp(textString,0.)=1)&(jj=0) set(handles.text1,String,8) ;elsetextString =strcat(textString,8);set(handles.text1,String,textString) endjj=0; % - Executes on button press in pushbutton9.function pushbutton9_Callback(hObject, eventdata, handles)% hObject handle to pushbutton

30、9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global jjtextString = get(handles.text1,String); if(strcmp(textString,0.)=1)&(jj=0) set(handles.text1,String,9) ;elsetextString =strcat(textString,9);set(handles.text

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1