MATLAB GUI for solving simultaneous equations

Hello readers! After a long break, I am again using this space to share with a MATLAB based code, which I implemented as a small personal mini project (or a so called minute project).

You may know that solving equations in MATLAB is not a big task, we can easily do so using matrices. But evertime entering the values using command prompt sometimes seems to be very frustating. So this prompted me to prepare a GUI based application using MATLAB.

In this post I want to share with you a Graphical User Interface (GUI) made using MATLAB programming which can solve simultaneous equations in 2 variables.

You can see in the screenshot of the interface, that you need to enter the values of the coefficients of x & y and on the click of the button “Calculate”, the values of x and y will be displayed in the ‘answer’ section of the dialog box.

Image of MATLAB GUI for solving simulataneous equations

This program also takes care of the failure cases of solving simultaneous equations. Eg. The case when there are more than 1 unique solution i.e. Infinite solutions, the answer will be shown as ‘Inf’ that is Infinity in MATLAB’s language.

So the code for this GUI development is given below:


function varargout = mygui(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @mygui_OpeningFcn, ...
                   'gui_OutputFcn',  @mygui_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    gui_mainfcn(gui_State, varargin{:});
function mygui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = mygui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
R=[a1 b1;a2 b2];

Important Note: Just copying and pasting this set of program may not work. You need another file named as ‘mygui.fig’ which I had created for this program. So download the given set of code from the link given below:

[Download Link]

Download the zipped folder and extract both the files in it then run the m-file using MATLAB software.

I welcome your feedback on this application.

Content is copyrighted © www.123mylist.com