精华内容
下载资源
问答
  • Matlab GUI设计计算器

    2021-04-06 16:28:16
    适用于学习Matlab GUI设计人群
  • MATLAB GUI实现计算器设计

    万次阅读 多人点赞 2018-05-28 22:52:22
    1.先打开matlab新建GUI文件 2.选择路径(左边是默认的不用改) 然后点击ok 3.此时界面会弹出一个小框 4.建立计算器界面(贴上我设计的界面,不许嘲笑我的设计) 5.细致讲解一下,这里...

    1.先打开matlab新建GUI文件

    新建GUI文件

    2.选择路径(左边是默认的不用改)

    选择路径

    然后点击ok

    3.此时界面会弹出一个小框

    弹出框

    4.建立计算器界面(贴上我设计的界面,不许嘲笑我的设计)

    界面设计

    5.细致讲解一下,这里的按键和显示框的是怎么实现的

    A.显示框: 选择edit text
    显示框
    在右边屏幕拉取即可
    显示框
    如图所示,新建两个即可,左边作为输入屏,右边作为输入结果的显示屏
    双击该框,弹出一个窗口,窗口下拉,里面有该显示框的属性
    显示框的属性
    string值为显示框显示的值
    Tag为显示框的名字
    (现在这个计算器需要显示框和输出框,如果没有新建其他的edit框,默认新建的第一个edit框的名字为edit1,第二个为edit2)

    B.数字按钮和字符按钮
    点击push button 新建按钮,需要几个建几个
    按钮
    双击之后在string那一栏改成你所需要的按钮
    按钮值
    回车之后,如图所示
    改好的按钮值

    6.把界面雏形做出之后,我们需要去实现计算器的操作

    A.首先改0~9的数字键(需要点击后在edit1上显示该数字)
    右键点击你需要改的button之后会出现一个窗口选择view callbacks->callback,然后会打开一个函数,蓝色字体所在的位置是该button所在的位置的代码
    代码所在
    按照这个方式将自己的代码改成自己所需要的数字
    handles.后面加的是自己所需要将显示的文本框的名字

    textString = get(handles.edit1,‘String’);
    textString = strcat(textString,‘6’);
    set(handles.edit1,‘String’,textString);
    guidata(hObject, handles);

    B.对于计算符号
    计算符号

    textString = get(handles.edit1,‘String’);
    textString = strcat(textString,’+’);
    set(handles.edit1,‘String’,textString);
    guidata(hObject, handles);

    加减乘除只需用换一下就好
    C.对于AE操作
    AE

    textString = get(handles.edit1,‘String’);
    textString = get(handles.edit2,‘String’);
    set(handles.edit1,‘String’,’’);
    set(handles.edit2,‘String’,’’);
    guidata(hObject, handles);

    D.对于back操作
    back

    textString=get(handles.edit1,‘String’);
    as=char(textString);
    n=length(textString);
    textString=as(1:n-1);
    set(handles.edit1,‘String’,textString)
    guidata(hObject, handles);

    E.退出操作
    退出

    close(gcf);

    7.初始化操作

    A.需要对edit1和edit2进行初始化,使代码运行时,文本框里为空白(需要在opening里改函数)
    初始化

    set(handles.edit1,‘string’,’’);
    set(handles.edit2,‘string’,’’);

    B.需要将edit1的结果在edit2中显示出来(需要改计算那个button的函数值)
    计算

    textString = get(handles.edit1,‘String’);
    aa = eval(textString);
    set(handles.edit2,‘String’,aa);
    guidata(hObject, handles);

    使其显示在edit2上
    点击运行即可实现计算器。
    计算器

    function varargout = text2(varargin)
    % TEXT2 MATLAB code for text2.fig
    %      TEXT2, by itself, creates a new TEXT2 or raises the existing
    %      singleton*.
    %
    %      H = TEXT2 returns the handle to a new TEXT2 or the handle to
    %      the existing singleton*.
    %
    %      TEXT2('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in TEXT2.M with the given input arguments.
    %
    %      TEXT2('Property','Value',...) creates a new TEXT2 or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before text2_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to text2_OpeningFcn via varargin.
    %
    %      *See GUI Options on GUIDE's 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 text2
    
    % Last Modified by GUIDE v2.5 28-May-2018 19:45:49
    
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @text2_OpeningFcn, ...
                       'gui_OutputFcn',  @text2_OutputFcn, ...
                       'gui_LayoutFcn',  [] , ...
                       'gui_Callback',   []);
    if nargin && ischar(varargin{1})
        gui_State.gui_Callback = str2func(varargin{1});
    end
    
    if nargout
        [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    else
        gui_mainfcn(gui_State, varargin{:});
    end
    % End initialization code - DO NOT EDIT
    
    
    % --- Executes just before text2 is made visible.
    function text2_OpeningFcn(hObject, eventdata, handles, varargin)
    % This function has 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 text2 (see VARARGIN)
    
    % Choose default command line output for text2
    set(handles.edit1,'string','');
    set(handles.edit2,'string','');
    
    handles.output = hObject;
    
    % Update handles structure
    guidata(hObject, handles);
    
    % UIWAIT makes text2 wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
    
    
    % --- Outputs from this function are returned to the command line.
    function varargout = text2_OutputFcn(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 handles structure
    varargout{1} = handles.output;
    
    
    
    function edit1_Callback(hObject, eventdata, handles)
    % hObject    handle to edit1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    % Hints: get(hObject,'String') returns contents of edit1 as text
    %        str2double(get(hObject,'String')) returns contents of edit1 as a double
    
    
    % --- Executes during object creation, after setting all properties.
    function edit1_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to edit1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
    
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    
    
    % --- 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 (see GUIDATA)
    textString = get(handles.edit1,'String');
    aa = eval(textString);
    set(handles.edit2,'String',aa);
    guidata(hObject, handles);
    
    
    function edit2_Callback(hObject, eventdata, handles)
    % hObject    handle to edit2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    
    % Hints: get(hObject,'String') returns contents of edit2 as text
    %        str2double(get(hObject,'String')) returns contents of edit2 as a double
    
    
    % --- Executes during object creation, after setting all properties.
    function edit2_CreateFcn(hObject, eventdata, handles)
    % hObject    handle to edit2 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
    
    % Hint: edit controls usually have a white background on Windows.
    %       See ISPC and COMPUTER.
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    
    
    % --- Executes on button press in pushbutton2.
    function pushbutton2_Callback(hObject, eventdata, 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)
    textString = get(handles.edit1,'String');
    textString = strcat(textString,'7');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    
    % --- 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    structure with handles and user data (see GUIDATA)
    textString = get(handles.edit1,'String');
    textString = strcat(textString,'8');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton4.
    function pushbutton4_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)
    textString = get(handles.edit1,'String');
    textString = strcat(textString,'9');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- 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 version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    textString = get(handles.edit1,'String');
    textString = strcat(textString,'4');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in 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)
    textString = get(handles.edit1,'String');
    textString = strcat(textString,'5');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton7.
    function pushbutton7_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton7 (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.edit1,'String');
    textString = strcat(textString,'6');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- 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)
    textString = get(handles.edit1,'String');
    textString = strcat(textString,'1');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton9.
    function pushbutton9_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton9 (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.edit1,'String');
    textString = strcat(textString,'2');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton10.
    function pushbutton10_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton10 (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.edit1,'String');
    textString = strcat(textString,'3');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton11.
    function pushbutton11_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton11 (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.edit1,'String');
    textString = strcat(textString,'0');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton12.
    function pushbutton12_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton12 (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.edit1,'String');
    textString = strcat(textString,'+');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton13.
    function pushbutton13_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton13 (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.edit1,'String');
    textString = get(handles.edit2,'String');
    set(handles.edit1,'String','');
    set(handles.edit2,'String','');
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton14.
    function pushbutton14_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton14 (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.edit1,'String');
    textString = strcat(textString,'-');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton15.
    function pushbutton15_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton15 (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.edit1,'String');
    textString = strcat(textString,'*');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton16.
    function pushbutton16_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton16 (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.edit1,'String');
    textString = strcat(textString,'/');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton17.
    function pushbutton17_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton17 (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.edit1,'String');
    textString = strcat(textString,'4');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton18.
    function pushbutton18_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton18 (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.edit1,'String');
    textString = strcat(textString,'7');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton19.
    function pushbutton19_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton19 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    close(gcf);
    
    
    % --- Executes on button press in pushbutton20.
    function pushbutton20_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton20 (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.edit1,'String');
    as=char(textString);
    n=length(textString);
    textString=as(1:n-1);
    set(handles.edit1,'String',textString)
    guidata(hObject, handles);
    
    
    % --- Executes on button press in pushbutton21.
    function pushbutton21_Callback(hObject, eventdata, handles)
    % hObject    handle to pushbutton21 (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.edit1,'String');
    textString = strcat(textString,'.');
    set(handles.edit1,'String',textString);
    guidata(hObject, handles);
    
    
    展开全文
  • matlab GUI计算器设计

    2013-08-25 18:45:27
    matlab GUI设计计算器,可根据需要修改程序
  • 利用matlabGUI设计计算器

    热门讨论 2010-05-16 23:04:31
    自己用matlab实现计算器,可实现单位数的加减乘除,对于其他的运算可根据加减乘除的示例来添加。 让你对MATLABGUI设计有更深刻的理解,容易上手。
  • matlab GUI设计
  • 基于 MATLABGUI 计算器设计的应用 matlab 课程大作业 姓名卢伟峰 学号 084633237 班级电科 082 指导教师朱静 摘要 matlab 是一种用于算法开发数据可视化数据分析以及数值 计算的高级技术计算语言和交互式环境使用...
  • MATLAB GUI计算器.zip

    2020-02-16 14:07:56
    MATLAB GUI计算器 课程设计制作,包括‘+’‘-’‘*’‘/’功能以及括号等,无bug,可以直接运行
  • matlab gui 计算器设计与实现

    千次阅读 2020-07-25 13:55:48
    仿照win7自带的计算机用matlab gui做了个计算器,所有功能均已实现。 win7自带的计算器如下图所示。 本文实现的计算器如下图所示 参考代码:ai52learn

    仿照win7自带的计算机用matlab gui做了个计算器,所有功能均已实现。

    win7自带的计算器如下图所示。

    本文实现的计算器如下图所示

    参考代码:ai52learn

    展开全文
  • matlab的简易计算器GUI设计,给新手做参考,熟悉matlabGUI设计
  • function varargout = calculator(varargin)% CALCULATOR MATLAB code for calculator.fig% CALCULATOR, by itself, creates a new CALCULATORor raises the existing% singleton*.%% H =CALCULATOR returns the ...

    function varargout = calculator(varargin)

    % CALCULATOR MATLAB code for calculator.fig

    %  CALCULATOR, by itself, creates a new CALCULATOR

    or raises the existing

    %  singleton*.

    %

    %  H =

    CALCULATOR returns the handle to a new CALCULATOR or the handle

    to

    %  the

    existing singleton*.

    %

    %  CALCULATOR('CALLBACK',hObject,eventData,handles,...)

    calls the local

    %  function named CALLBACK in CALCULATOR.M with the

    given input arguments.

    %

    %  CALCULATOR('Property','Value',...) creates a new

    CALCULATOR or raises the

    %  existing singleton*.  Starting

    from the left, property value pairs are

    %  applied to the GUI before calculator_OpeningFcn

    gets called.  An

    %  unrecognized property name or invalid value makes

    property application

    %  stop.  All inputs are passed to

    calculator_OpeningFcn via varargin.

    %

    %  *See

    GUI Options on GUIDE's 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

    calculator

    % Last Modified by GUIDE v2.5 28-Sep-2016 21:27:55

    % Begin initialization code - DO NOT EDIT

    gui_Singleton = 1;

    gui_State = struct('gui_Name',  mfilename, ...

    'gui_Singleton',  gui_Singleton,

    ...

    'gui_OpeningFcn', @calculator_OpeningFcn,

    ...

    'gui_OutputFcn',

    @calculator_OutputFcn, ...

    'gui_LayoutFcn',  [] , ...

    'gui_Callback',  []);

    if nargin && ischar(varargin{1})

    gui_State.gui_Callback =

    str2func(varargin{1});

    end

    if nargout

    [varargout{1:nargout}] =

    gui_mainfcn(gui_State, varargin{:});

    else

    gui_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 has 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 calculator

    handles.output = hObject;

    % Update handles structure

    guidata(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,

    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 handles structure

    varargout{1} = 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 (see GUIDATA)

    textString=get(handles.text1,'String');

    e=bin2dec(textString);

    set(handles.text1,'String',e);%按键“二进制转十进制”

    % --- Executes on button press in pushbutton2.

    function pushbutton2_Callback(hObject, eventdata,

    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)

    textString=get(handles.text1,'String');

    e=dec2bin(textString);

    set(handles.text1,'String',e);%按键“十进制转二进制”

    % --- 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  structure with

    handles and user data (see GUIDATA)

    textString=get(handles.text1,'String');

    textString=strcat(textString,'sin');

    set(handles.text1,'String',textString);%设置符号“sin”

    % --- Executes on button press in pushbutton4.

    function pushbutton4_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)

    textString=get(handles.text1,'String');

    textString=strcat(textString,'cos');

    set(handles.text1,'String',textString);%设置符号“cos”

    % --- 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 version of MATLAB

    % handles  structure with

    handles and user data (see GUIDATA)

    textString=get(handles.text1,'String');

    if

    ((strcmp(textString,'1.57')==1)||(strcmp(textString,'-1.57')==1))

    set(handles.edit1,'String','inf');

    else

    textString=strcat(textString,'tan');

    set(handles.text1,'String',textString);%设置符号“tan”

    end

    % --- Executes on button press in 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)

    textString=get(handles.text1,'String');

    textString=strcat(textString,'pi');

    set(handles.text1,'String',textString);%设置符号“π”

    % --- Executes on button press in pushbutton7.

    function pushbutton7_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton7 (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');

    if (strcmp(textString,'0')==1)

    set(handles.text1,'String','error');

    else

    a=strread(textString,'%f');

    a=log2(a);

    set(handles.text1,'String',a);

    end  %设置符号“log2”

    % --- 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)

    set(handles.text1,'String','');%按键“清空”

    % --- Executes on button press in pushbutton9.

    function pushbutton9_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton9 (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,'asin');

    set(handles.text1,'String',textString);%设置符号“arcsin”

    % --- Executes on button press in pushbutton10.

    function pushbutton10_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton10 (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,'acos');

    set(handles.text1,'String',textString);%设置符号“arccos”

    % --- Executes on button press in pushbutton11.

    function pushbutton11_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton11 (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,'atan');

    set(handles.text1,'String',textString);%设置符号“arctan”

    % --- Executes on button press in pushbutton12.

    function pushbutton12_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton12 (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,'(');

    set(handles.text1,'String',textString);%设置符号“(”

    % --- Executes on button press in pushbutton13.

    function pushbutton13_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton13 (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,')');

    set(handles.text1,'String',textString);%设置符号“)”

    % --- Executes on button press in pushbutton14.

    function pushbutton14_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton14 (see GCBO)

    % eventdata  reserved - to be defined in a

    future version of MATLAB

    % handles  structure with

    handles and user data (see GUIDATA)

    close(gcf);%按键“退出”

    % --- Executes on button press in pushbutton15.

    function pushbutton15_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton15 (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,'1');

    set(handles.text1,'String',textString);%上面三句设置数字“1”,对其存储并输出

    % --- Executes on button press in pushbutton16.

    function pushbutton16_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton16 (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,'4');

    set(handles.text1,'String',textString);%上面三句设置数字“4”,对其存储并输出

    % --- Executes on button press in pushbutton17.

    function pushbutton17_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton17 (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,'7');

    set(handles.text1,'String',textString);%上面三句设置数字“7”,对其存储并输出

    % --- Executes on button press in pushbutton18.

    function pushbutton18_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton18 (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,'2');

    set(handles.text1,'String',textString);%上面三句设置数字“2”,对其存储并输出

    % --- Executes on button press in pushbutton19.

    function pushbutton19_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton19 (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);%上面三句设置数字“5”,对其存储并输出

    % --- Executes on button press in pushbutton20.

    function pushbutton20_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton20 (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,'8');

    set(handles.text1,'String',textString);%上面三句设置数字“8”,对其存储并输出

    % --- Executes on button press in pushbutton21.

    function pushbutton21_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton21 (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,'3');

    set(handles.text1,'String',textString);%上面三句设置数字“3”,对其存储并输出

    % --- Executes on button press in pushbutton22.

    function pushbutton22_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton22 (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',textString);%上面三句设置数字“6”,对其存储并输出

    % --- Executes on button press in pushbutton23.

    function pushbutton23_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton23 (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,'9');

    set(handles.text1,'String',textString);%上面三句设置数字“9”,对其存储并输出

    % --- Executes on button press in pushbutton24.

    function pushbutton24_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton24 (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);%上面三句设置数字“0”,对其存储并输出

    % --- Executes on button press in pushbutton25.

    function pushbutton25_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton25 (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');

    w=length(textString);

    t=char(textString);

    textString=t(1:w-1);%将w个字符串转成w-1个,即删除了末位字符

    set(handles.text1,'String',textString);%按键“back”

    % --- Executes on button press in pushbutton26.

    function pushbutton26_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton26 (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,'.');

    set(handles.text1,'String',textString);%上面三句设置符号“.”,对其存储并输出

    % --- Executes on button press in pushbutton27.

    function pushbutton27_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton27 (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,'+');

    set(handles.text1,'String',textString);%上面三句设置符号“+”,对其存储并输出

    % --- Executes on button press in pushbutton28.

    function pushbutton28_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton28 (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,'-');

    set(handles.text1,'String',textString);%上面三句设置符号“-”,对其存储并输出

    % --- Executes on button press in pushbutton29.

    function pushbutton29_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton29 (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,'*');

    set(handles.text1,'String',textString);%上面三句设置符号“*”,对其存储并输出

    % --- Executes on button press in pushbutton30.

    function pushbutton30_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton30 (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,'/');

    set(handles.text1,'String',textString);%上面三句设置符号“÷”,对其存储并输出

    % --- Executes on button press in pushbutton31.

    function pushbutton31_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton31 (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');

    s=eval_r(textString);

    set(handles.text1,'String',s);%上面三句设置符号“=”,对其存储并输出

    % --- Executes on button press in pushbutton32.

    function pushbutton32_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton32 (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');

    if (strcmp(textString,'0')==1)

    set(handles.text1,'String',0);

    else

    a=strread(textString,'%f');

    a=sqrt(a);

    set(handles.text1,'String',a);

    end  %设置符号“√”

    % --- Executes on button press in pushbutton33.

    function pushbutton33_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton33 (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,'^2');

    set(handles.text1,'String',textString);%设置符号“^2”

    % --- Executes on button press in pushbutton34.

    function pushbutton34_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton34 (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,'^3');

    set(handles.text1,'String',textString);%设置符号“^3”

    % --- Executes on button press in pushbutton36.

    function pushbutton36_Callback(hObject, eventdata,

    handles)

    % hObject  handle to

    pushbutton36 (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,'^');

    set(handles.text1,'String',textString);%设置符号“^”,n次方

    展开全文
  • Matlab GUI工具 简易计算器设计

    千次阅读 2014-02-17 10:51:19
    Matlab GUI工具实现计算器的简易功能:加减乘除、倒数、平方、平方根、取负。 GUI 界面上包含的控件: 1. 4 个 text(静态文本):白色条框内含 2 个 text,一上一下,“Made in Rui” 为 标记 2. 22 个 ...

    用Matlab GUI工具实现计算器的简易功能:加减乘除、倒数、平方、平方根、取负。

    GUI 界面上包含的控件:

    1. 4 个 text(静态文本):白色条框内含 2 个 text,一上一下,“Made in Rui” 为 标记

    2. 22 个 pushbotton(按钮)

    实现方法:

    输入:各个按钮实现数字和运算符号的输入,其中数字连续输入表示一个数字从高位至低位输入,可包含小数点,可为负,输入在下 text;

    运算:加减乘除为一类,倒数、平方、平方根为一类。前一类可作运算关键点,后一类仅对当前数字进行运算;

    输出:运算结果显示在上 text;隐藏在左上角 text 只输出 0 或 1,作为运算标记。

    此外,功能中包含清空与退格键


    .fig 文件与 .m 文件可供下载:(下载链接,CSDN 不能上传文件,有些尴尬)

    http://download.csdn.net/detail/zstu_wangrui/6928483

    关于各位网友指正与交流。

    展开全文
  • MATLAB·gui设计简单计算器应用实例

    万次阅读 多人点赞 2019-06-19 23:26:51
    MATLAB 程序设计基础之gui设计 简单计算器应用实例 一、实验目的 掌握Matlab图形用户界面的设计流程 二、实验内容 用matlab设计有图形界面的计算器程序,其中清空和退出功能使用菜单栏实现(例子:calculator1) 三...
  • 设计计算器时,主要是考虑到计算器的易用性、功能的常用程度进行计算器界面与功能的设计。通过调整控件和文本的布局及颜色,使界面简单大方、布局合理,达到界面友好的效果。 计算器设计时主要利用到get和set两个...
  • 基于MATLABGUI设计简易计算器

    千次阅读 2018-11-10 13:10:31
    MATLAB语言基于GUI设计简易计算器 GUI界面的设置 主页----新建----应用程序----GUIDE 进入下图所示界面 点击确定,即可生成GUI设计界面。 设计计算器界面,放置按键和显示屏,并对按键进行定义。 OR(按钮)设置...
  • 出于兴趣爱好自学了一段时间的MATLAB,然后学习自制了一个属于自己的一个计算器,现在将我的第一个GUI分享给大家。(MATLAB版本为R2019a) 一、准备工作 ①首先在MATLAB中的命令行窗口输入guide,之后会出现如下界面...
  • matlab[GUI设计]简易计算器的设计

    千次阅读 2020-11-14 19:04:47
    今天想跟大家分享一个简单的案例——基于MATLAB GUI的简易计算器设计。在进行计算器设计的时候,主要考虑到计算器的易用性、功能的常用程度和人机之间的良好交互。MATLAB作为一个商用数学软件,内置了多种函数,...
  • matlab gui 实战之计算器

    千次阅读 2019-03-23 14:38:02
    他隔段时间会布置一道实战作业,这次的作业是复现计算器界面和功能,分别有难度一,难度二,难度三,我是小弱鸡,三是不可能选的,自然选了难度二,之前用matlab gui都是用guide拖拽设计界面再写回调函数,这次是纯...

空空如也

空空如也

1 2 3 4
收藏数 76
精华内容 30
关键字:

matlabgui设计计算器

matlab 订阅