system of simultaneous
equations is easy in Matlab. It is, maybe, the
operation in science and engineering, too. Solving a set of equations in
linear algebra on a computer is nowadays as basic
as doing arithmetic additions using
a calculator. Let's see how easy Matlab makes this task.
Go to Video Summary
We'll solve the set of
To solve these equations, no prior
knowledge of matrix
algebra or linear methods is required. The first two steps described
below are really
basic for most people who know just a little bit of linear algebra...
the following set of equations for our example.
-6x = 2y - 2z + 15
4y - 3z = 3x + 13
2x + 4y - 7z = -9
rearrange the equations.
Write each equation with
all the unknown
variables on the left-hand side and all known quantities on the right
side. Thus, for the equations given, rearrange them such that all terms
and z are
on the left side of the equal sign.
-6x - 2y + 2z = 15
-3x + 4y - 3z = 13
+ 4y - 7z = -9
the equations in a matrix form
To write the equations in
the matrix form Ax
is the vector of unknowns (you have to arrange the unknowns in vector x),
the coefficients of the unknowns in matrix A
and the constants on the rigth hand of the equations in vector b.
In this particualar example, the unknown column vector is
= [x y z]'
the coefficient matrix is
= [-6 -2 2
-3 4 -3
2 4 -7]
and the known constant column vector is
= [15 13 -9]'
Note than the columns of A
simply are the coefficients of each unknown from all the three
expressed equations. The apostrophe
at the end of vectors x
means that those vectors are column vectors, not row ones (it is Matlab
the simultaneous equations in Matlab
Enter the matrix A
and vector b,
and solve for vector x
with the command
x = A\b
(note that the '\' symbol is different
from the ordinary
The Matlab answer to the lines above is:
You can test the result by performing the substitution and multiplying Ax
to get b,
And the Matlab answer is:
which corresponds to
the column vector b,
system of equations easy
Summary - Solve Linear Systems
'Simultaneous Equations' to home
'Simultaneous Equations' to 'Linear Algebra Menu'