You are on page 1of 36

PowerPoint to accompany

Solving linear
system using
MATLAB

Copyright © 2005. The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
A singular problem refers to a set of equations
having either no unique solution or no solution at all.
For example, the set

3x − 4y = 5

6x − 8y = 10

is singular and has no unique solution because the


second equation is identical to the first equation,
multiplied by 2. The graphs of these two equations
are identical. All we can say is that the solution must
satisfy y = (3x − 5)/4, which describes
an infinite number of solutions.
The equations

6x – 10y = 2

3x – 4y = 5

have graphs that intersect at the solution y = 4, x = 7.


On the other hand, the set

3x − 4y = 5
6x − 8y = 3
is singular but has no solution. The graphs of these two
equations are distinct but parallel (see Figure 6.1–2).
Because they do not intersect, no solution exists.
The graphs of two equations that intersect at a solution.
Figure 6.1–1
Parallel graphs indicate that no solution exists.
Figure 6.1–2
Matrix notation enables us to represent multiple equations
as a single matrix equation. For example, consider the
following set:
2x1 + 9x2 = 5
3x1 − 4x2 = 7
This set can be expressed in vector-matrix form as

2 9 x1 5
=
3 −4 x2 7
which can be represented in the following compact form

Ax = b
For the equation set Ax = b,

● if |A| = 0, then there is no unique solution.

● Depending on the values in the vector b, there


may be no solution at all, or an infinite number of
solutions.
MATLAB provides the left-division method for
solving the equation set Ax = b. The left-division
method is based on Gauss elimination.

To use the left-division method to solve for x, type


x = A\b. For example,

>> A = [6, -10; 3, -4]; b = [2; 5];


>> x = A\b
x =
7 4

This method also works in some cases where the


number of unknowns does not equal the number
of equations.
Matrix Rank
The rank of a matrix is a measure of the number of linearly independent rows or
columns in the matrix.

Matrix A : Row 2 of matrix A is a scalar multiple of row 1; that is, row 2 is equal to
twice row 1. Therefore, rows 1 and 2 are linearly dependent. Matrix A has only
one linearly independent row, so its rank is 1.

Matrix B : All of its rows are linearly independent, so the rank of matrix B is 3
Calculate the Rank in MATLAB
Rank vs Linear system equation
If a linear system of equation with m equation and n
unknowns:
Ax = b
The augmented matrix is formed by concatenating
the vector b onto the matrix A:

[A b]

The system has a solution if and only if rank(A) =


rank(A b). If the rank is equal
to n, then the system has a unique solution. If
rank(A) = rank(A b) but the rank
< n, there are an infinite number of solutions
Linear system has unique solution only if
determinant (det) not equal to 0.
if det = 0 then check the rank of equation. If the rank
is equal then the system can be solved using left
division (\) or pseudoinverse (pinv)

If det ≠ 0 and the matrix coefficient is square, we could use


inverse (inv)
or
Matrix decomposition
■ MATLAB can be used to quickly generate the LU
decomposition and solve linear system equation. We
can find the LU decomppsition by writing :

You might also like