3x+2y-z =-1
First,
rearrange the equations.
Write each equation with all unknown
quantities on the left-hand side and all known quantities on the right
side. Thus, for the equations given, rearrange them such that all terms
involving x,
y
and z are
on the left side of the equal sign.Second, write
the equations in a matrix form.
To write the equations in the matrix form Ax
= b,
where x
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 right hand of the equations in vector b.
In this particular example, the unknown column x
= [x y z]'
the coefficient matrix is
A
= [-6 -2 2
-3 4 -3
2 4 -7]
and the known constant column vector is
b
= [15 13 -9]'
Note than the columns of A
are simply the coefficients of each unknown from all the three
expressed equations. The apostrophe
at the end of vectors x
and b
means that those vectors are column vectors, not row ones (it is Matlab
notation).
Third, solve
the simultaneous equations in Matlab.
Enter the matrix A
and vector b,
and solve for vector x
with the instruction 'x = A\b' (note that the '\' sign is different
from the ordinary
division '/'
signThe Matlab answer is:
A =
-6
-2 2
-3
4 -3
2
4 -7
b =
15
13
-9
x =
-2.7273
2.7727
2.0909
You can test the result by performing the substitution and multiplying Ax
to get b,
like this:
A*x
And the Matlab answer is:
Ans =
15.0000
13.0000
-9.0000
>>
which corresponds to b,
indeed.
rearrange the equations.
Write each equation with all unknown
quantities on the left-hand side and all known quantities on the right
side. Thus, for the equations given, rearrange them such that all terms
involving x,
y
and z are
on the left side of the equal sign.Second, write
the equations in a matrix form.
To write the equations in the matrix form Ax
= b,
where x
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 right hand of the equations in vector b.
In this particular example, the unknown column x
= [x y z]'
the coefficient matrix is
A
= [-6 -2 2
-3 4 -3
2 4 -7]
and the known constant column vector is
b
= [15 13 -9]'
Note than the columns of A
are simply the coefficients of each unknown from all the three
expressed equations. The apostrophe
at the end of vectors x
and b
means that those vectors are column vectors, not row ones (it is Matlab
notation).
Third, solve
the simultaneous equations in Matlab.
Enter the matrix A
and vector b,
and solve for vector x
with the instruction 'x = A\b' (note that the '\' sign is different
from the ordinary
division '/'
signThe Matlab answer is:
A =
-6
-2 2
-3
4 -3
2
4 -7
b =
15
13
-9
x =
-2.7273
2.7727
2.0909
You can test the result by performing the substitution and multiplying Ax
to get b,
like this:
A*x
And the Matlab answer is:
Ans =
15.0000
13.0000
-9.0000
>>
which corresponds to b,
indeed.