Introduction:
Asetoftwoormoreequations,eachcontainingtwoormorevariableswhosevaluescansimultaneouslysatisfybothoralltheequationsintheset,thenumberofvariablesbeingequaltoorlessthanthenumberofequationsintheset.
We use Graphical User Interface
(GUI) made using MATLAB programming which can solve simultaneous equations in 2
variables.
This program also takes care of
the failure cases of solving simultaneous equations. E.g. 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.
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.
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.
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:
Code:
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});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
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)
a1=str2num(get(handles.a1,'String'));
b1=str2num(get(handles.b1,'String'));
c1=str2num(get(handles.c1,'String'));
a2=str2num(get(handles.a2,'String'));
b2=str2num(get(handles.b2,'String'));
c2=str2num(get(handles.c2,'String'));
R=[a1 b1;a2 b2];
V=[c1;c2];
I=inv(R)*V;
set(handles.ans1,'String',I(1,1))
set(handles.ans2,'String',I(2,1))
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.
[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.
Related Post :
Matlab
- 3 Phase Inverter Simulation using Simulink
- Horner's Algorithm Implementation using MATLAB
- MATLAB GUI Star to Delta & Vice Versa Converter Application
- MATLAB function to plot Instantaneous Voltage, Current and Power
- MATLAB program – Newton Raphson Method
Softwares
No comments:
Post a Comment