[GUI application] Matrix calculator implemented by Matlab

Interface Design

Effect Display

Body Source

%%matrix additiona=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)     c='error.Matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = a+b ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end
%%Matrix Subtractiona=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)     c='error.Matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = a-b ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end

%%Matrix Point Multiplicationa=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)     c='error.Matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = a.*b ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end
%%matrix multiplicationa=str2num(get(handles.edit1,'string'));b=str2num(get(handles.edit2,'string'));[ia ja]=size(a);[ib jb]=size(b);if ja ~= ib                 c='error.Inner matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = a*b ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end
%%Matrix Point Divisiona=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)     c='error.Matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = a./b ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end
%%Left Division of Matrixa=str2num(get(handles.edit1,'string'));b=str2num(get(handles.edit2,'string'));[ia ja]=size(a);[ib jb]=size(b);if ia ~= ib         c='error.Matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = a\b ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end
%%Right Division of Matrixa=str2num(get(handles.edit1,'string'));b=str2num(get(handles.edit2,'string'));[ia ja]=size(a);[ib jb]=size(b);if ia ~= ib         c='error.Matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = a/b ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end
%%Rank of Matrixa=str2num(get(handles.edit1,'string'));c=a';set(handles.text1,'string',num2str(c))
 a=str2num(get(handles.edit1,'string')); result =rank(a) ; c= num2str(result); set(handles.text1,'String',c) guidata(hObject, handles);
%%Inversea=str2num(get(handles.edit1,'string'));[ia ja]=size(a);if  ia~= ja                   c='error.Matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    if  abs(det(a))<1e-6                     c='error.Matrix is singular to working precision.';        set(handles.text1,'String',c)        guidata(hObject, handles);    else        result = inv(a) ;        c = num2str(result);        set(handles.text1,'String',c)        guidata(hObject, handles);    endend

%%determinanta=str2num(get(handles.edit1,'string'));[ia ja]=size(a);if  ia ~= ja                   c='error.Matrix dimensions must agree.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = det(a) ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end
%%Seek 2-norma=str2num(get(handles.edit1,'string'));result = norm(a);c = num2str(result);set(handles.text1,'String',c)guidata(hObject, handles)
%%seek LU decomposea=str2num(get(handles.edit1,'string'));[L,U,P]=lu(a);result = [L;U;P] ;c= num2str(result);set(handles.text1,'String',c)guidata(hObject, handles)

%%seek AX=Ba=str2num(get(handles.edit1,'string'));b=str2num(get(handles.edit2,'string'));[ia ja]=size(a);[ib jb]=size(b);if ia ~= ib    c='error.';    set(handles.text1,'String',c)    guidata(hObject, handles);else    if ia ~=ja                                c='error.Matrix must be square.';        set(handles.text1,'String',c)        guidata(hObject, handles);    else        if  det(a) == 0                            c='error.Matrix is singular to working precision.';            set(handles.text1,'String',c)            guidata(hObject, handles);        else            result = a\b ;            c = num2str(result);            set(handles.text1,'String',c)            guidata(hObject, handles);        end    endend

a=str2num(get(handles.edit1,'string'));result = rref(a);c= num2str(result);set(handles.text1,'String',c)guidata(hObject, handles);
%%Evaluating eigenvaluesa=str2num(get(handles.edit1,'string'));[ia ja]=size(a);if  ia ~= ja                    c='error.Matrix must be square .';    set(handles.text1,'String',c)    guidata(hObject, handles);else    result = eig(a) ;    c= num2str(result);    set(handles.text1,'String',c)    guidata(hObject, handles);end%Steppeda=str2num(get(handles.edit1,'string'));b=str2num(get(handles.edit2,'string'));[ia ja]=size(a);[ib jb]=size(b);if ia ~= ib         c='error.Matrix dimensions must agree.';    set(handles.edit34,'String',c)    guidata(hObject, handles);else    result = rref(a) ;    c= num2str(result);    set(handles.edit34,'String',c)    guidata(hObject, handles);end%%Inverta=str2num(get(handles.edit1,'string'));[ia ja]=size(a);if  ia ~= ja                    c='error.Matrix must be square .';    set(handles.edit34,'String',c)    guidata(hObject, handles);else    result =a' ;    c= num2str(result);    set(handles.edit34,'String',c)    guidata(hObject, handles);end

 

Menu structure design

Menu design is only for click-and-dial, not copy!!!Create menus as shown by Menu Editor.File menu calls Simple Calculator, Scientific Calculator, Programmer Calculator and Exits; Help menu calls Program Description and Copyright.

 

 

File menu design

By setting the visibility properties of the panel where the Simple Calculator, Scientific Calculator, and Programmer Calculator are located, you can invoke the corresponding calculator module by clicking on the Simple Calculator, Scientific Calculator, and Programmer Calculator options under the File menu.When invoking the Simple Calculator module, you only need to set the visual property value of the panel on which the Simple Calculator is located to "on", and the visual property value of the other calculators to "off"; set the checked property value of the Simple Calculator menu item to "on", and the checked property value of the remaining menu items to "off".The rest of the module calls work similarly.The code is as follows:

function simple_Callback(hObject, eventdata, handles)set(handles.science_clc,'Visible','off');set(handles.simple_clc,'Visible','on');set(handles.clc_p,'Visible','off');set(handles.jy_clc,'Position',[103.8 20.769 84.0 33.692]);set(handles.simple,'checked','on');set(handles.science,'checked','off');set(handles.programmer,'checked','off');

 

Previous Review >>>

Optimal Route Planning for Robots Based on Raster Map-Genetic Algorithms

[Pattern Recognition] MAT Fingerprint Recognition

Mapping epidemics with matlab

Automatic recognition of bank card number by matlab

[Optimizing Problem] Optimizing by Genetic Algorithms

Multi-Feature Based Enhanced Image Quality Evaluation without Reference Image Quality Evaluation

Twenty-five original articles were published. 7 were praised. 10,000 visits+

Tags: calculator MATLAB REST

Posted on Fri, 06 Mar 2020 18:05:37 -0800 by lalabored