www.pudn.com > matrixd.rar > my.m


function varargout = my(varargin) 
% MY M-file for my.fig 
% Last Modified by GUIDE v2.5 13-Nov-2004 18:36:22
 
% Begin initialization code - DO NOT EDIT 
gui_Singleton = 1; 
gui_State = struct('gui_Name',       mfilename, ... 
                   'gui_Singleton',  gui_Singleton, ... 
                   'gui_OpeningFcn', @my_OpeningFcn, ... 
                   'gui_OutputFcn',  @my_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 my is made visible. 
function my_OpeningFcn(hObject, eventdata, handles, varargin) 
 
% Choose default command line output for my 
handles.output = hObject; 
 
% Update handles structure 
guidata(hObject, handles); 
 
% UIWAIT makes my wait for user response (see UIRESUME) 
% uiwait(handles.figure1); 
 
 
% --- Outputs from this function are returned to the command line. 
function varargout = my_OutputFcn(hObject, eventdata, handles) 
 
% Get default command line output from handles structure 
varargout{1} = handles.output; 


% --- Executes during object creation, after setting all properties.
function screen_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function buttoncallback() 
global str1 
global str2 
global mutex 
h=findobj('tag','screen') 
h1=findobj(gco) 
v=get(h,'string') 
r=get(h1,'string') 
 if mutex==2 
   clearscreen 
 end 
if mutex==1 
        v=get(h,'string') 
        if v=='0' 
         set(h,'string',' ') 
         end 
         str1=get(h,'string') 
         str1=strcat(str1,r) 
         set(h,'string',str1) 
     else 
        if str2=='0' 
            set(h,'string',' ') 
        end 
         str2=get(h,'string') 
         str2=strcat(str2,r) 
         set(h,'string',str2) 
   end 
%---------------------------------------------- 
 
% --- Executes on button press in button1. 
function button1_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button0. 
 
function button0_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button7. 
function button7_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button4. 
function button4_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button5. 
function button5_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button2. 
function button2_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button3. 
function button3_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button6. 
function button6_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button9. 
function button9_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button8. 
function button8_Callback(hObject, eventdata, handles) 
buttoncallback 
% --- Executes on button press in button_dot. 
function button_dot_Callback(hObject, eventdata, handles) 
buttoncallback 
 
% --- Executes on button press in button_add. 
function button_add_Callback(hObject, eventdata, handles) 
opra 
% --- Executes on button press in button_minus. 
function button_minus_Callback(hObject, eventdata, handles) 
opra 
% --- Executes on button press in button_times. 
function button_times_Callback(hObject, eventdata, handles) 
opra 
% --- Executes on button press in button_sign. 
function button_sign_Callback(hObject, eventdata, handles) 
% --- Executes on button press in button_divide. 
function button_divide_Callback(hObject, eventdata, handles) 
opra 
% --- Executes on button press in button_power. 
function button_power_Callback(hObject, eventdata, handles) 
opra 
% --- Executes on button press in button_sqrt. 
function button_sqrt_Callback(hObject, eventdata, handles) 
opra 
% --- Executes on button press in button_log. 
function button_log_Callback(hObject, eventdata, handles) 
opra 
%---------------------------------------------------------- 
%---------------------------------------------------------- 
function opra() 
global x 
global y 
global s 
global str1 
global str2 
global mutex 
x=str2num(str1) 
h=findobj(gco) 
y=str2num(str2) 
  switch s 
    case '+'  
        x=x+y 
    case '-' 
        x=x-y 
    case '×' 
        x=x*y 
    case '÷' 
        x=x/y 
    case 'x^n' 
        x=power(x,y) 
         case 'sqrt'  
        x=sqrt(x) 
     case 'log'  
        x=log(x)  
   
    otherwise('unknown  structor') 
  end       
str1=num2str(x) 
   h1=findobj('tag','screen') 
   set(h1,'string',str1)   
   s=get(h,'string') 
   str2='0' 
   mutex=0 
  
 
 
%------------------------------------ 
 
% --- Executes on button press in button_equal. 
function button_equal_Callback(hObject, eventdata, handles) 
global str1 
global str2 
global mutex 
global x 
global y 
global s 
y=str2num(str2) 
switch s 
    case '+'  
        x=x+y 
    case '-' 
        x=x-y 
    case '×' 
        x=x*y 
    case '÷' 
        x=x/y 
    case 'x^n' 
        x=power(x,y) 
         case 'sqrt'  
        x=sqrt(x) 
     case 'log'  
        x=log(x)  
          
    otherwise('unknown  OP') 
end       
str1=num2str(x) 
h=findobj('tag','screen') 
set(h,'string',str1) 
mutex=2 
 
 
% --- Executes on button press in button_canceal. 
function button_canceal_Callback(hObject, eventdata, handles) 
global str1 
global str2 
global s 
global mutex 
str1='0' 
str2='0' 
s=' ' 
mutex=1 
h=findobj('tag','screen') 
set(h,'string','0') 
% --- Executes on button press in button_on. 
function button_on_Callback(hObject, eventdata, handles) 
 
% --- Executes on button press in button_off. 
function button_off_Callback(hObject, eventdata, handles) 
% -------------------------------------------------------------------- 
function menu_setbackcolor_Callback(hObject, eventdata, handles) 
 
% -------------------------------------------------------------------- 
function menu_exit_Callback(hObject, eventdata, handles) 
 
% -------------------------------------------------------------------- 
function menu_aboutcaculator_Callback(hObject, eventdata, handles) 
msgbox('谢谢使用老虎计算器1.0版!','关于计算器'); 
 
% -------------------------------------------------------------------- 
function menu_aboutauthor_Callback(hObject, eventdata, handles) 
msgbox('作者:顾学虎  QQ:28186032 班级:信息020408','关于作者');