⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jisuanqi.m

📁 用MATLAB实现的计算器 用的是GUI制作的
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = jisuanqi(varargin)
% JISUANQI M-file for jisuanqi.fig
%      JISUANQI, by itself, creates a new JISUANQI or raises the existing
%      singleton*.
%
%      H = JISUANQI returns the handle to a new JISUANQI or the handle to
%      the existing singleton*.
%
%      JISUANQI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in JISUANQI.M with the given input arguments.
%
%      JISUANQI('Property','Value',...) creates a new JISUANQI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before jisuanqi_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to jisuanqi_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 jisuanqi

% Last Modified by GUIDE v2.5 20-Nov-2007 19:41:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @jisuanqi_OpeningFcn, ...
                   'gui_OutputFcn',  @jisuanqi_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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 jisuanqi is made visible.
function jisuanqi_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 jisuanqi (see VARARGIN)

% Choose default command line output for jisuanqi
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes jisuanqi wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = jisuanqi_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;
%定义calculate函数,用于两个数的计算
function answer=calculate(Number1,Number2,opvalue)
switch (opvalue)
    case '+'
       answer=Number1+Number2;%加法
    case '-'
        answer=Number1-Number2;%减法
    case '*'
        answer=Number1*Number2;%乘法
    case '/'
       answer=Number1/Number2;%除法
    case '^'
        answer=Number1^Number2;%求幂次
    case 'log'
        answer=log(Number1)/log(Number2); %取对数
    otherwise
end

% --- Executes on button press in pushbutton1.
%按键startfunction 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)
global   Number1;% --- 操作数1
global   Number2;% --- 操作数2
global   opvalue;% --- 运算符
global   IsStart;% --- 开启键
global   IsNew;% --- 操作数新得开始
Number1='';
Number2='';
opvalue = ''; 
IsNew='true';
IsStart='true';
set(handles.text2,'string','0');
% --- Executes on button press in pushbutton4.
%按键9function 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)
global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','9');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'9');
        set(handles.text2,'String',num);
 end   
end
 % --- Executes on button press in pushbutton13.
%按键8function 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)
global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','8');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'8');
        set(handles.text2,'String',num);
 end   
end
% --- Executes on button press in pushbutton14.
%按键6function 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)
global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','6');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'6');
        set(handles.text2,'String',num);
 end   
end% --- Executes on button press in pushbutton15.
%按键5function 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)
global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','5');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'5');
        set(handles.text2,'String',num);
 end   
end% --- Executes on button press in pushbutton16.
%按键7function 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)
global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','7');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'7');
        set(handles.text2,'String',num);
 end   
end% --- Executes on button press in pushbutton17.
%按键4function 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)global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','4');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'4');
        set(handles.text2,'String',num);
 end   
end% --- Executes on button press in pushbutton18.
%按键3function 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)global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','3');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'3');
        set(handles.text2,'String',num);
 end   
end% --- Executes on button press in pushbutton19.
%按键2function 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)global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','2');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'2');
        set(handles.text2,'String',num);
 end   
end% --- Executes on button press in pushbutton20.
%按键1function 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)global IsNew;
global IsStart;
 if strcmp(IsStart,'true')==1
 if strcmp(IsNew,'true')==1
        set(handles.text2,'String','1');
        IsNew='false',;
    else
        num=strcat(get(handles.text2,'String'),'1');
        set(handles.text2,'String',num);
 end   
end% --- Executes on button press in pushbutton21.
%按键0function 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)
global IsNew;
global IsStart;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -