Solving a system of equations with two unknowns is a very easy cake to bite but when the number of unknown exceed two, solving the system of equations becomes complicated and time-consuming.
In this post, we are going to show you how you can use your computer and Matlab to solve a system of many equations.
Caution: the following technique works only when the number of equations and the number of unknowns are the same. We will solely work will linear equations
Can Matlab solve a system of equations?
Yes, Matlab can help you easily solve a system of equations. Let’s jump into some examples and show you how you go about it.
Using Matlab to Solve a system of equation with two unknowns
Let’s consider the following system of equations
The above equation can be written in the matrix form
The equation can be rewritten as
Now we are set to use Matlab!
A=[2 3;1 1]; B=[8;3]; X=inv(A)*B
The last line does not have; at the end.
You will see an answer like this
Which simply means that
Let’s elaborate a little more in detail here before moving forward. What we have done above is the following.
We have written the equation in the form
Where
So to have at the end the equation on the form
Example 2: System of the equation with three unknowns
let’s consider the following system of equations
Using the same technique we used above we can write the system in the following form
Giving commands to Matlab will look like the following
A=[1 3 -2;3 2 -1;2 -1 -3]; B=[1;2;13]; X=inv(A)*B
To end up with the following result
Final thought
If you are working on a system of equations where the number of unknowns is equal to the number of equations, this method is a good way to go. This restriction is due to the fact that using the system of matrices to solve such system of equations requires that the matrix A is invertible. If there are no possibilities of finding the inv(A) then this method is totally useless.