function varargout = untitled(varargin)
% UNTITLED M-file for 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('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 01-Dec-2006 13:28:35
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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 xianshi_Callback(hObject, eventdata, handles)
% hObject handle to xianshi (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 xianshi as text
% str2double(get(hObject,'String')) returns contents of xianshi as a double
% --- Executes during object creation, after setting all properties.
function xianshi_CreateFcn(hObject, eventdata, handles)
% hObject handle to xianshi (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 qi.
function qi_Callback(hObject, eventdata, handles)
% hObject handle to qi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'7');
set(handles.xianshi,'String',num);
Number2=str2num(num);
else
num=7;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- Executes on button press in ba.
function ba_Callback(hObject, eventdata, handles)
% hObject handle to ba (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'8');
set(handles.xianshi,'String',num);
Number2=str2num(num);
else
num=8;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- Executes on button press in jiu.
function jiu_Callback(hObject, eventdata, handles)
% hObject handle to jiu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'9');
set(handles.xianshi,'String',num);
Number2=str2num(num);
else
num=9;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- Executes on button press in chufa.
function chufa_Callback(hObject, eventdata, handles)
% hObject handle to chufa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global op
global Number1
global Number2
Number1=str2num(get(handles.xianshi,'String'))
set(handles.xianshi,'String',' ')
op='/';
% --- Executes on button press in si.
function si_Callback(hObject, eventdata, handles)
% hObject handle to si (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.edit1,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'4');
set(handles.xianshi,'String',num);
Number2=str2num(num);
else
num=4;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- Executes on button press in wu.
function wu_Callback(hObject, eventdata, handles)
% hObject handle to wu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'5');
set(handles.edit1,'String',num);
Number2=str2num(num);
else
num=5;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- Executes on button press in liu.
function liu_Callback(hObject, eventdata, handles)
% hObject handle to liu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'6');
set(handles.xianshi,'String',num);
Number2=str2num(num);
else
num=6;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- Executes on button press in yi.
function yi_Callback(hObject, eventdata, handles)
% hObject handle to yi (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'1');
set(handles.xianshi,'String',num);
Number2=str2num(num);
else
num=1;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- Executes on button press in ling.
function ling_Callback(hObject, eventdata, handles)
% hObject handle to ling (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'0');
set(handles.xianshi,'String',num);
Number2=str2num(num);
else
num=0;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- 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)
global op
global Number1
global Number2
Number1=str2num(get(handles.xianshi,'String'))
if Number1 errordlg('真数必须大于0','Error');
else
result=log2(Number1)
set(handles.xianshi,'String',result)
end
% --- Executes on button press in san.
function san_Callback(hObject, eventdata, handles)
% hObject handle to san (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'3');
set(handles.xianshi,'String',num);
Number2=str2num(num);
else
num=3;
set(handles.xianshi,'String',num);
Number2=num;
end
% --- Executes on button press in er.
function er_Callback(hObject, eventdata, handles)
% hObject handle to er (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global num
global Number2
tem=get(handles.xianshi,'String');
if strcmp(tem,'0')~=1;
num=strcat(get(handles.xianshi,'String'),'2');
set(handles.edit1,'String',num);
Number2=str2num(num);
else
num=2;
set(handles.edit1,'String',num);
Number2=num;
end
% --- Executes on button press in dian.
function dian_Callback(hObject, eventdata, handles)
% hObject handle to dian (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
num=strcat(get(handles.edit1,'String'),'.');
set(handles.edit1,'String',num);
% --- Executes on button press in chenfa.
function chenfa_Callback(hObject, eventdata, handles)
% hObject handle to chenfa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global op
global Number1
global Number2
Number1=str2num(get(handles.edit1,'String'))
set(handles.edit1,'String',' ')
op='*';
% --- Executes on button press in jianfa.
function jianfa_Callback(hObject, eventdata, handles)
% hObject handle to jianfa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global op
global Number1
global Number2
Number1=str2num(get(handles.edit1,'String'))
set(handles.edit1,'String',' ')
op='-';
% --- Executes on button press in jiafa.
function jiafa_Callback(hObject, eventdata, handles)
% hObject handle to jiafa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global op
global Number1
global Number2
Number1=str2num(get(handles.edit1,'String'))
set(handles.edit1,'String',' ')
op='+';
% --- Executes on button press in qingling.
function qingling_Callback(hObject, eventdata, handles)
% hObject handle to qingling (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit1,'String','0')
% --- Executes on button press in dengyu.
function dengyu_Callback(hObject, eventdata, handles)
% hObject handle to dengyu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global Number1
global Number2
global op
switch (op)
case '+'
result=Number1+Number2
set(handles.edit1,'String',result);
case '-'
result=Number1-Number2;
set(handles.edit1,'String',result);
case '*'
result=Number1*Number2;
set(handles.edit1,'String',result);
case '/'
result=Number1/Number2;
if Number2==0;
errordlg('除数不能为0','Error');
else
set(handles.edit1,'String',result);
end
case '^'
result=Number1^Number2;
set(handles.edit1,'String',result);
otherwise
end
% --- Executes on button press in kaifang.
function kaifang_Callback(hObject, eventdata, handles)
% hObject handle to kaifang (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global op
global Number1
global Number2
Number1=str2num(get(handles.edit1,'String'))
if Number1 errordlg('被开方数不能小于0','Error');
else
result=sqrt(Number1)
set(handles.edit1,'String',result)
end
% --- Executes on button press in chenfang.
function chenfang_Callback(hObject, eventdata, handles)
% hObject handle to chenfang (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global op
global Number1
global Number2
Number1=str2num(get(handles.edit1,'String'));
set(handles.edit1,'String',' ')
op='^';