gui设计的简易计算器附程序

上传人:第*** 文档编号:57329933 上传时间:2018-10-21 格式:PDF 页数:18 大小:195.78KB
返回 下载 相关 举报
gui设计的简易计算器附程序_第1页
第1页 / 共18页
gui设计的简易计算器附程序_第2页
第2页 / 共18页
gui设计的简易计算器附程序_第3页
第3页 / 共18页
gui设计的简易计算器附程序_第4页
第4页 / 共18页
gui设计的简易计算器附程序_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《gui设计的简易计算器附程序》由会员分享,可在线阅读,更多相关《gui设计的简易计算器附程序(18页珍藏版)》请在金锄头文库上搜索。

1、1电子信息工程系实验报告课程名称:MATLAB 应用实验项目名称:GUI 计算器设计实验时间:2012-11-22班级:测控 081姓名:学号:810707132实实 验验 目目 的的:1.熟悉 MATLAB 的菜单设计方法2. 熟悉 MATLAB 的主要控件使用方法3. 熟悉 MATLAB 的 GUI 设计流程4.运用 MATLAB 的 GUI 设计一个简单的计算器实实 验验 环环 境境: MATLAB7.8 实实 验验 内内 容容: function varargout = jisuanqi1(varargin)% JISUANQI1 M-file for jisuanqi1.fig%JI

2、SUANQI1, by itself, creates a new JISUANQI1 or raises the existing%singleton*.%H = JISUANQI1 returns the handle to a new JISUANQI1 or the handle to%the existing singleton*.%JISUANQI1(CALLBACK,hObject,eventData,handles,.) calls the local%function named CALLBACK in JISUANQI1.M with the given input arg

3、uments.%JISUANQI1(Property,Value,.) creates a new JISUANQI1 or raises the%existing singleton*.Starting from the left, property value pairs are%applied to the GUI before jisuanqi1_OpeningFunction gets called.An%unrecognized property name or invalid value makes property application%stop.All inputs are

4、 passed to jisuanqi1_OpeningFcn via varargin.%*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 jisuanqi1% Last Modified by GUIDE v2.5 05-Dec-2010 22:24:59% Begin i

5、nitialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name,mfilename, .成绩:指导教师(签名) :2gui_Singleton,gui_Singleton, .gui_OpeningFcn, jisuanqi1_OpeningFcn, .gui_OutputFcn,jisuanqi1_OutputFcn, .gui_LayoutFcn, , .gui_Callback,);if nargin endif nargoutvarargout1:nargout = gui_mainfcn(gu

6、i_State, varargin:);elsegui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before jisuanqi1 is made visible.function jisuanqi1_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObjecthandle to figure% even

7、tdatareserved - to be defined in a future version of MATLAB% handlesstructure with handles and user data (see GUIDATA)% varargincommand line arguments to jisuanqi1 (see VARARGIN)% 以下是本实验初始化部分程序的代码:global c p t c1 f;f=0;t=0;p=2;c1=num2str(0);c= 0.;set(handles.edit1,String,c);guidata(hObject, handles)

8、;% Choose default command line output for jisuanqi1handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes jisuanqi1 wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout =

9、 jisuanqi1_OutputFcn(hObject, eventdata, handles)% varargoutcell array for returning output args (see VARARGOUT);3% hObjecthandle to figure% eventdatareserved - to be defined in a future version of MATLAB% handlesstructure with handles and user data (see GUIDATA)% Get default command line output fro

10、m handles structurevarargout1 = handles.output;% - Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObjecthandle to pushbutton3 (see GCBO)% eventdatareserved - to be defined in a future version of MATLAB% handlesstructure with handles and user data

11、 (see GUIDATA)% 以下是本实验数字8的程序代码:global t f c;if f=;c=0;c=8+str2num(c)*10;c= num2str(c);set(handles.edit1,String,c);guidata(hObject, handles);elseif t=0;c=8+str2num(c)*10;c= num2str(c);set(handles.edit1,String,c);guidata(hObject, handles);elsec=strcat(c,8);set(handles.edit1,String,c);guidata(hObject,

12、handles);t=t+1;end% - Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObjecthandle to pushbutton4 (see GCBO)% eventdatareserved - to be defined in a future version of MATLAB% handlesstructure with handles and user data (see GUIDATA)% 以下是本实验数字5的程序代

13、码:global t f c;if f=;c=0;c=5+str2num(c)*10;c= num2str(c);set(handles.edit1,String,c);guidata(hObject, handles);4elseif t=0;c=5+str2num(c)*10;c= num2str(c);set(handles.edit1,String,c);guidata(hObject, handles);elsec=strcat(c,5);set(handles.edit1,String,c);guidata(hObject, handles);t=t+1;end% - Execut

14、es on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObjecthandle to pushbutton5 (see GCBO)% eventdatareserved - to be defined in a future version of MATLAB% handlesstructure with handles and user data (see GUIDATA)% 以下是本实验数字2的程序代码:global t f c;if f=;c=0;c=2

15、+str2num(c)*10;c= num2str(c);set(handles.edit1,String,c);guidata(hObject, handles);elseif t=0;c=2+str2num(c)*10;c= num2str(c);set(handles.edit1,String,c);guidata(hObject, handles);elsec=strcat(c,2);set(handles.edit1,String,c);guidata(hObject, handles);t=t+1;end% - Executes on button press in pushbut

16、ton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObjecthandle to pushbutton6 (see GCBO)% eventdatareserved - to be defined in a future version of MATLAB% handlesstructure with handles and user data (see GUIDATA)% 以下是本实验+/-的程序代码:global c t p;if rem(p,2)=0;5c=strcat(-,c);set(handles.edit1,String,c);guidata(hObject, handles);p=p+1;elsec=strrep(c,-,);set(handles.edit

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号