function varargout = lihaojin(varargin)
% LIHAOJIN M-file for lihaojin.fig
% LIHAOJIN, by itself, creates a new LIHAOJIN or raises the existing
% singleton*.
%
% H = LIHAOJIN returns the handle to a new LIHAOJIN or the handle to
% the existing singleton*.
%
% LIHAOJIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LIHAOJIN.M with the given input arguments.
%
% LIHAOJIN('Property','Value',...) creates a new LIHAOJIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before lihaojin_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to lihaojin_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 lihaojin
% Last Modified by GUIDE v2.5 13-Sep-2014 13:41:31
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @lihaojin_OpeningFcn, ...
'gui_OutputFcn', @lihaojin_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 lihaojin is made visible.
function lihaojin_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 lihaojin (see VARARGIN)
% Choose default command line output for lihaojin
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes lihaojin wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = lihaojin_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)
set(handles.pushbutton1,'TooltipString','矩阵相加');
A = str2num((get(handles.edit1,'String')));
B = str2num((get(handles.edit2,'String')));
[iA jA]=size(A);
[iB jB]=size(B);
if iA ~= iB | jA ~= jB |(iA ~= iB & jA ~= jB)%判断A、B是否满足相加条件
R='矩阵格式不满足相加的条件 请您及时修改.';
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
else
result = A + B ;
R = num2str(result);
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
end
% 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)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
set(handles.pushbutton2,'TooltipString','矩阵相减');
A =str2num((get(handles.edit1,'String')));
B =str2num((get(handles.edit2,'String')));
[iA jA]=size(A);
[iB jB]=size(B);
if iA ~= iB | jA ~= jB |(iA ~= iB & jA ~= jB)%判断A、B是否满足相减条件
R='矩阵格式不满足相减的条件,请您修改.';
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
else
result = A - B ;
R = num2str(result);
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
end
% 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)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
set(handles.pushbutton3,'TooltipString','矩阵相乘');
A = str2num((get(handles.edit1,'String')));
B =str2num((get(handles.edit2,'String')));
[iA jA]=size(A);
[iB jB]=size(B);
if jA~=iB %判断A、B是否满足相乘条件
R='矩阵格式不满足相乘的条件,请您修改.';
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
else
result = A * B ;
R = num2str(result);
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
end
% 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)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
set(handles.pushbutton4,'TooltipString','矩阵左除');
A = str2num((get(handles.edit1,'String')));
B = str2num((get(handles.edit2,'String')));
[iA jA]=size(A);
[iB jB]=size(B);
if iA~=iB %判断A、B是否满足左除条件
R='矩阵格式不满足左除的条件,请您修改.';
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
else
result = A \ B ;
R = num2str(result);
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
end
% 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)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
set(handles.pushbutton5,'TooltipString','矩阵点乘');
A = str2num((get(handles.edit1,'String')));
B = str2num((get(handles.edit2,'String')));
result = A .* B ;
R = num2str(result);
set(handles.edit3,'String',R,'max',8)
guidata(hObject, 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)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
set(handles.pushbutton6,'TooltipString','A求行列式');
A = str2num((get(handles.edit1,'String')));
[iA jA]=size(A);
if iA ~=jA %判断A是否为方阵
R='error.edit must be square.';
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
else
result = det(A) ;
R = num2str(result);
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
end
% 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)
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
set(handles.pushbutton7,'TooltipString','A矩阵开方');
A = str2num(get(handles.edit1,'String'));
result = sqrt(A);
R = num2str(result);
set(handles.edit3,'String',R,'max',8)
guidata(hObject, 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)
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
set(handles.pushbutton8,'TooltipString','A矩阵求秩');
A = str2num((get(handles.edit1,'String')));
result = rank(A) ;
R = num2str(result);
set(handles.edit3,'String',R,'max',8)
guidata(hObject, handles);
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future vers