Matrices
Matrices
TRAVEL
DEFINITION 2.1
A matrix A with size m × n is a rectangular array of
numbers, which contains m rows and n columns.
a 11 ... a1 j ... a 1n
.. ... .. ... ..
. . .
ai 1
A= ... ai j ... ai n
.. ... .. ... ..
. . .
a m1 . . . a m j . . . a mn
DEFINITION 2.2
a1 j
a
2j
A matrix with only one column .. is called a
.
an j
column vector. ¡ ¢
A matrix with only one row ai 1 ai 2 . . . ai n is
called a row vector.
¡ ¢
If A i ∗ = ai 1 ai 2 . . . ai n is the i −th row of matrix A ,
a1 j
a
2j
1 É i É m, and A ∗ j = .. is the j −th column if
.
am j
matrix A , 1 É j É n then
A 1∗
A ¡
2∗ ¢
A = .. = A ∗1 A ∗2 . . . A ∗n
.
A m∗
MATRICES AND MATRIX OPERATIONS 8 / 107
Matrices Row vector, column vector
EXAMPLE 2.1
µ ¶
1 −4 5
Matrix A = consists of:
0 3 −2 2×3
¡ ¢ ¡ ¢
2 row vectors 1 −4 5 , 0 3 −2
µ ¶ µ ¶ µ ¶
1 −4 5
and 3 column vectors , ,
0 3 −2
ZERO MATRICES
DEFINITION 2.3
A matrix whose entries are all zero is called a zero
matrix, that is ai j = 0, ∀i , j.
EXAMPLE 2.2
µ ¶
0 0 0
A= is the zero matrix of order 2 × 3.
0 0 0
DEFINITION 2.4
A matrix A with n rows and n columns is called a
square matrix of order n
a 11 . . . a 1i . . . a 1n
.. ... .. ... ..
. . .
A= ai 1 . . . ai i . . . ai n
.
.. ... .. . . . ...
. .
a n1 . . . a ni . . . a nn
EXAMPLE 2.3
1 2 3
A = 0 −3 −2 is the square matrix of order 3. The
5 4 −5
entries on the main diagonal of A are 1, −3, −5
IDENTITY MATRICES
DEFINITION 2.5
1 0 ... 0
0 1 ... 0
A square matrix I = .. .. . . , with 10 s on the
. . . ..
.
0 0 ... 1
main diagonal and zeros elsewhere, i.e.
(a i i = 1, i = 1, ..n; a i j = 0, ∀i 6= j ) is called an identity
matrix of order n and is denoted by I or I n
EXAMPLE 2.4
1 0 0
I = 0 1 0 is the identity matrix of order 3.
0 0 1
TRANSPOSE OF A MATRIX
DEFINITION 2.6
If A = (ai j )m×n is any m × n matrix, then the transpose
of A , denoted by A T = (a j i )n×m is defined to be the
n × m matrix that results by interchanging the rows
and columns of A; that is,
a 11 a 12 ... a 1n a 11 a 21 . . . a m1
a
21 a 22 ... a 2n T a 12 a 22 . . . a m2
A = .. , A = ..
. .. . . . ... .. . . . ...
. . .
a m1 a m2 . . . a mn a 1n a 2n . . . a mn
EXAMPLE 2.5
If µ ¶
1 3 5
A=
2 4 6
then
1 2
⇒ AT = 3 4
5 6
DEFINITION 3.1
Elementary Row Operations on matrix A are the
following operations:
1
Interchange 2 rows r i ↔ r j
2
Multiply a row through by a nonzero constant:
r i → λr i , (λ 6= 0).
3
Add a constant times one row to another:
r i → r i + λ.r j , ∀λ
x − 2y + 3z = 9
1 −2 3 9
−x + 3y = −4 −1 3 0 −4
2x − 5y + 5z = 17 2 −5 5 17
Add the first row to the
Add the first equation to
second row to produce a
the second equation.
new second row.
x − 2y + 3z = 9
1 −2 3 9
y + 3z = 5 0 1 3 5
2x − 5y + 5z = 17 2 −5 5 17
Add −2 times the first
Add −2 times the first
row to the third row
equation to the third
to produce a new third
equation.
row.
x − 2y + 3z = 9
1 −2 3 9
y + 3z = 5 0 1 3 5
−y − z = −1 0 −1 −1 −1
Add the second equa- Add the second row to
tion to the third equa- the third row to produce
tion. a new third row.
x − 2y + 3z = 9
1 −2 3 9
y + 3z = 5 0 1 3 5
2z = 4 0 0 2 4
Multiply the third row
Multiply the third equa- 1
1 by to produce a new
tion by 2
2 third row.
x − 2y + 3z = 9
1 −2 3 9
y + 3z = 5 0 1 3 5
z = 2 0 0 1 2
The last matrix is said to
x = 1; y = −1; z = 2
be in row-echelon form
DEFINITION 3.2
A matrix is called reduced row-echelon form if it has the
following properties
1 If a row does not consist entirely of zeros, then the first
nonzero number in the row is a 1, which is called a leading 1.
2 If there are any rows that consist entirely of zeros, then they
are grouped together at the bottom of the matrix.
3 In any two successive rows that do not consist entirely of
zeros, the leading 1 in the lower row occurs farther to the
right than the leading 1 in the higher row.
4 Each column that contains a leading 1 has zeros everywhere
else in that column.
DEFINITION 3.3
A matrix that has the first 3 properties is said to be in
row-echelon form.
MATRICES AND MATRIX OPERATIONS 24 / 107
Elementary Row Operations Echelon form
EXAMPLE 3.1
The following matrices are in reduced
row-echelon
0 1 −2 0 1
1 0 0 4 1 0 0 0 0 0 1 3
form: 0 1 0 7 ; 0 1 0 ; ;
0 0 0 0 0
0 0 1 −1 0 0 1
0 0 0 0 0
µ ¶
0 0
.
0 0
EXAMPLE 3.2
The
followingmatrices
are
in
row-echelon form:
1 4 −3 7 1 1 0 0 1 2 6 0
0 1 6 2 ; 0 1 0 ; 0 0 1 −1 0 .
0 0 1 5 0 0 0 0 0 0 0 1
EXAMPLE 3.3
Transform the following matrix to row-echelon form
and reduced row-echelon form
0 0 −2 0 7 12
2 4 −10 6 12 28
2 4 −5 6 −5 −1
1 2 −5 3 6 14
r 3 →r 3 −5r 2
0 0 1 0 −7/2 −6 −−−−−−−→
0 0 5 0 −17 −29
1 2 −5 3 6 14
r 3 →2r 3
0 0 1 0 −7/2 −6 −−−−→
0 0 0 0 1/2 1
1 2 −5 3 6 14
0 0 1 0 −7/2 −6
0 0 0 0 1 2
The procedure produces a row-echelon form is
called Gaussian Elimination
1 2 −5 3 0 2 1 2 0 3 0 7
r 1 →r 1 +r 2 ×5
0 0 1 0 0 1 −−−−−−−−→ 0 0 1 0 0 1
0 0 0 0 1 2 0 0 0 0 1 2
The last matrix is in reduced row echelon form. The
procedure described for reducing a matrix to
reduced row echelon form is called Gauss-Jordan
elimination.
RANK OF A MATRIX
DEFINITION 4.1
We denote A −→ B to show that B is the matrix that
results from A by performing some of the Elementary
Row Operations.
DEFINITION 4.2
If A m×n −→ B m×n , where B is in row-echelon form, then
rank of the matrix A is the number of leading 1’s of
matrix B and is denoted by r (A).
1
r (A) = 0 ⇔ A = 0
2
0 É r (A m×n ) É min{m, n}
Elementary Row Operations
3
If A −−−−−−−−−−−−−−−−−−−−−−−−−−−→ B then
r (B ) = r (A).
4
r (A) = r (A T ).
EXAMPLE 4.1
0 2 −4
For matrix A = −1 −4 5 , transform A to
3 1 7
row-echelon form using elementary row operations.
Determine the rank of the matrix A.
0 2 −4 r 2 →−r 2 1 4 −5
r 2 ↔r 1
−1 −4 5 −−−−−→ 0 2 −4
3 1 7 3 1 7
r 3 →r 3 −3r 1 1 4 −5
r 2 → 12 r 2 r 3 →r 3 +11r 2
−−−−−−−→ 0 1 −2 −−−−−−−→
0 −11 22
1 4 −5
0 1 −2 . Rank of matrix A is 2.
0 0 0
DEFINITION 5.1
Two matrices A and B are defined to be equal if they
have the same size and their corresponding entries
are equal, i.e.
EXAMPLE 5.1
Find real numbers x, y, z, t such that the following 2
matrices are equal
µ ¶ µ ¶
x + y 2z + t 3 7
=
x −y z −t 1 5
x+y = 3
x = 2
x−y
= 1 y = 1
⇔
2z + t = 7
z = 4
z −t = 5 t = −1
DEFINITION 5.2
If A = (ai j )m×n is any matrix and α is any scalar, then
the product αA obtained by the multiplying each
entry of the matrix A by α. The matrix αA is said to be
a scalar multiple of A , i.e.
PROPERTIES
1
1.A = A
2
0.A = 0,
3
α.0 = 0, ∀α ∈ R, 0 is the zero matrix.
4
α(βA) = (αβ)A, ∀α, β ∈ R.
EXAMPLE 5.2
µ ¶
1 2 3
If A = then
5 4 −5
µ ¶ µ ¶
3×1 3×2 3×3 3 6 9
3A = =
3 × 5 3 × 4 3 × (−5) 15 12 −15
DEFINITION 5.3
If A and B are matrices of the same size, then the sum
A + B is the matrix obtained by adding the entries of B
to the corresponding entries of A.
PROPERTIES
EXAMPLE 5.3
µ ¶ µ ¶
1 4 3 3 1 1
+ =
8 −3 2 4 −1 0
µ ¶ µ ¶
1+3 4+1 3+1 4 5 4
= =
8 + 4 −3 − 1 2 + 0 12 −4 2
28 5 5 28 × 3 + 5 × 1 + 5 × 0
23 9 6
3 23 × 3 + 9 × 1 + 6 × 0
22 9 7 . 1 = 22 × 3 + 9 × 1 + 7 × 0 =
21 10 7 0 21 × 3 + 10 × 1 + 7 × 0
21 9 8 21 × 3 + 9 × 1 + 8 × 0
89 (Man. Utd)
78 (Man. City)
= 75 (Chelsea)
(Arsenal)
73
72 (Tottenham)
HISTORICAL NOTE
DEFINITION 5.4
If A = (ai j )m×n ∈ M
m×n
(K ), B = (b i j )n×p ∈ M n×p (K ).
a 11 a 12 ... a 1n
. .. .. ..
. b 11 b 12 . . . b 1 j . . . b 1p
. . . .
. .. .. .. .. ..
..
ai 1 ai 2 ... ai n . =
. . . . .
. .. .. ..
. b n1 b n2 . . . b n j . . . b np n×p
. . . .
a m1 a m2 . . . a mn m×n
c 11 c 12 . . . c1 j . . . c 1p
. .. .. .. .. ..
.
. . . . . .
ci 1
ci 2 ... ci j . . . ci p then the product AB is the matrix
. .. .. .. .. ..
.
. . . . . .
c m1 c m2 . . . c m j . . . c mp m×p
n
C = A.B = (c i j )m×p whose entries are defined by c i j =
P
a i k .b k j , i = 1..m; j = 1..p
k=1
REMARK
EXAMPLE 5.4
Find product A.B where
1
¡ ¢ 2
A = 2 −1 4 5 , B =
1×4 0
−1 4×1
1
¢ 2
¡
A.B = 2 −1 4 5 . =
0
−1
³ ´ ³ ´
2 × 1 + (−1) × 2 + 4 × 0 + 5 × (−1) = − 5
MATRICES AND MATRIX OPERATIONS
1×1 54 / 107
Operations on Matrices Matrix multiplication
EXAMPLE 5.5
Find product C = A.B where
µ ¶ 2 1 −1
2 3 1
A= , B = 1 3 −2 .
−1 0 1 2×3 0 2 1
3×3
µ 2 1 −1 ¶
2 3 1
. 1 3 −2 =
−1 0 1
0 2 1
2
¡ ¢
c 11 = 2 3 1 . 1 = 2 × 2 + 3 × 1 + 1 × 0 = 7
0
MATRICES AND MATRIX OPERATIONS 55 / 107
Operations on Matrices Matrix multiplication
1
¡ ¢
c 12 = 2 3 1 . 3 = 2 × 1 + 3 × 3 + 1 × 2 = 13
2
−1
¡ ¢
c 13 = 2 3 1 . −2 = 2 × (−1) + 3 × (−2) + 1 × 1 = −7
1
2
¡ ¢
c 21 = −1 0 1 . 1 = (−1) × 2 + 0 × 1 + 1 × 0 = −2
0
1
¡ ¢
c 22 = −1 0 1 . 3 = (−1) × 1 + 0 × 3 + 1 × 2 = 1
2
−1
¡ ¢
c 23 = −1 0 1 . −2 =
1
= (−1) × (−1) + 0 × (−2) + 1 × 1 = 2
Therefore,
µ ¶
7 13 −7
C = A.B = .
−2 1 2
PROPERTIES
1
(A.B ).C = A.(B.C ) = A.B.C
2
A.(B +C ) = A.B + A.C .
3
(B +C ).A = B.A +C .A
4
λ(AB ) = (λA).B = A.(λB ), λ ∈ R.
DEFINITION 5.5
If A is a square matrix and
p(x) = a 0 + a 1 x + a 2 x 2 + . . . + a m x m
EXAMPLE 5.6
· ¸
2 −1 2
Find p(A) for p(x) = x − 2x − 3 and A =
0 3
p(A) = A 2 − 2A − 3I =
· ¸2 · ¸ · ¸ · ¸
−1 2 −1 2 1 0 0 0
= −2 −3 =
0 3 0 3 0 1 0 0
ELEMENTARY MATRIX
DEFINITION 5.6
A matrix E is called an elementary matrix if it can be
obtained from an identity matrix I by performing a
single elementary row operation.
EXAMPLE 5.7
1 0 0 1 0 3
r 1 →r 1 +r 3 ×3
0 1 0 −−−−−−−−→ 0 1 0 .
0 0 1 0 0 1
EXAMPLE 5.8
Consider an 3 × 4 matrix A and elementary row
operation: adding 2 times the first row of matrix A to
the third row. Find the elementary matrix E such that
the product E A is the matrix that results when this
same row operation is performed on A .
r 3 →r 3 +2r 1
A 3×4 −−−−−−−→ B 3×4 ⇔ B 3×4 = E 3×3 .A 3×4
1 0 0 1 0 0
r 3 →r 3 +2r 1
I 3×3 = 0 1 0 −−−−−−−→ 0 1 0 = E 3×3
0 0 1 2 0 1
Suppose
a 11 a 12 a 13 a 14
r 3 →r 3 +2r 1
A = a 21 a 22 a 23 a 24 −−−−−−−→ B =
a 31 a 32 a 33 a 34
a 11 a 12 a 13 a 14
a 21 a 22 a 23 a 24
a 31 + 2a 11 a 32 + 2a 12 a 33 + 2a 13 a 34 + 2a 14
1 0 0 a 11 a 12 a 13 a 14
E .A = 0 1 0 . a 21 a 22 a 23 a 24 = B =
2 0 1 a 31 a 32 a 33 a 34
a 11 a 12 a 13 a 14
a 21 a 22 a 23 a 24
a 31 + 2a 11 a 32 + 2a 12 a 33 + 2a 13 a 34 + 2a 14
INVERSE OF A MATRIX
DEFINITION 6.1
If A is a square matrix, and if a matrix B of the same
size can be found such that
B A = AB = I , (4)
REMARK
AB = B A = I
EQUIVALENT STATEMENTS
THEOREM 6.1
If A is an n × n matrix, then the following statements
are equivalent
1
A is invertible
Elementary Row Operations
2
A −−−−−−−−−−−−−−−−−−−−−−−−−−→ I n
3
r (A) = n
INVERSION ALGORITHM
Elementary Row Operations
(A|I ) −−−−−−−−−−−−−−−−−−−−−−−−−−−→ (I |A −1 )
E n .E n−1 . . . . .E 2 E 1 .A = I
⇒ A −1 = E n .E n−1 . . . . .E 2 E 1
EXAMPLE 6.1
1 2 3
Find the inverse A −1 of A = 2 5 4
3 7 8
¯
1 2 3 ¯¯ 1 0 0 r 2 →r 2 −2r 1
r 3 →r 3 −3r 1
(A|I 3 ) = 2 5 4 ¯ 0 1 0 −−−−−−−→
¯
¯
3 7 8¯ 0 0 1
¯
1 2 3 ¯¯ 1 0 0 r 1 →r 1 −2r 2
r 3 →r 3 −r 2
0 1 −2 ¯ −2 1 0 −−−−−−−→
¯
¯
0 1 −1 ¯ −3 0 1
¯
1 0 7 ¯¯ 5 −2 0 r 1 →r 1 −7r 3
r 2 →r 2 +2r 3
0 1 −2 ¯ −2 1 0 −−−−−−−→
¯
¯
0 0 1 ¯ −1 −1 1
¯
1 0 0 ¯¯ 12 5 −7
−1
0 1 0 ¯ −4 −1 2 = (I 3 |A )
¯
¯
0 0 1 ¯ −1 −1 1
12 5 −7
⇒ A −1 = −4 −1 2
−1 −1 1
LESLEI MODEL
EXAMPLE 7.1
A population of rabbits raised in a research
laboratory has the characteristics listed below. (a)
Half of the rabbits survive their first year. Of those,
half survive their second year. The maximum life
span is 3 years. (b) During the first year, the rabbits
produce no offspring. The average number of
offspring is 6 during the second year and 8 during the
third year. The laboratory population now consists of
24 rabbits in the first age class, 24 in the second, and
20 in the third. How many rabbits will be in each age
class in 1 year, 2 years?
MATRICES AND MATRIX OPERATIONS 73 / 107
Leslie model
MARKOV CHAIN
EXAMPLE 8.1
In a city with 1000 householders there are 3
supermarkets A , B and C . At this month, there are
200, 500 and 300 householders that go to the
supermarkets A , B and C , respectively. After each
month, there are 10% of customers of A change to B ,
10% of those change to C ; 7% of customers of B
change to A , 3% of those change to C ; 8.3% of
customers of C change to A , 6.7% of those change to B .
Find the numbers of customers of each supermarket
after 1 month, 2 months.
MATRICES AND MATRIX OPERATIONS 76 / 107
Markov chain
THEOREM 8.1
Let P be the transition matrix of a Markov chain. The
i j -th entry p i(n)
j
of the matrix P n gives the probability
that the Markov chain, starting in state s j , will be in
state s i after n steps.
EXAMPLE 9.1
Consider a simple economic system consisting of 3
industries: electricity, water, and coal. Production, or
output, of one unit of electricity requires 0.5 unit of
itself, 0.25 unit of water, and 0.25 unit of coal.
Production of one unit of water requires 0.1 unit of
electricity, 0.6 unit of itself, and 0 units of coal.
Production of one unit of coal requires 0.2 unit of
electricity, 0.15 unit of water, and 0.5 unit of itself.
Find the input-output matrix for this system.
CLOSED SYSTEM
x i = d i 1 x 1 + d i 2 x 2 + ... + d i n x n
OPEN SYSTEM
x i = d i 1 x 1 + d i 2 x 2 + ... + d i n x n + e i
X = DX +E,
EXAMPLE 9.2
An economic system composed of 3 industries has the
input-output matrix
0.1 0.43 0
D = 0.15 0 0.37
0.23 0.03 0.02
SOLUTION.
X = D X + E ⇒ (I − D)X = E ⇒ X = (I − D)−1 E .
46616
X ≈ 51058
38014
To produce the given external demands, the outputs
of the 3 industries must be approximately 46616
units for the industry I, 51058 units for industry II,
and 38014 units for industry III.
APPLICATION IN CRYPTOGRAPHY
We need to encrypt the series of characters R U
CRAZY. Choose a rule of cryptography, for ex.,
transform the characters A → Z into the numbers
1 → 26, respectively, the white space is 27:
R U C R A Z Y
18 27 21 27 3 18 1 26 25
Rearrange the series into the matrix with 3 rows:
18 27 1
A = 27 3 26
21 18 25
MATRICES AND MATRIX OPERATIONS 89 / 107
Crytograply
R U C R A Z Y
⇒ 18 27 21 27 3 18 1 26 25
⇒ 39 63 21 45 57 18 26 28 25
We can recover A from B by A = K −1 B .
GRAPH THEORY
ADJACENCY MATRICES
DEFINITION 11.1
For a graph G of order n , the adjacency matrix,
denoted A(G), of graph G is an n by n matrix whose
(i , j )-th entry is determined as follows:
(
1, if vertex v i is adjacent to vertex v j
Ai j =
0, otherwise
0 1 120 101 0 00 1 10 030 0 217 11 13 11 10 4 16 23
1 0 166611 01010 01 110 00 001 007770 0 666 11 18 13 17 4 9 11 67
13 13 28 13 16 14 13 27
7
6 7 6 7
60 0 1 0 1 0 1 07 611 17 13 18 4 9 11 67
A(G) = 6 7
60 1 0 1 0 0 0 17 A (G) = 6
4 6 7 (2)
1 1 06661 010 0 00 0 01 07771 0 6664 9 14 9 4 10 4 27777
10 4 16 4 15 4 10 0
4 5 416 11 13 11 10 4 17 25
0 0 100 00010 10 101 10 000 00 1 0
2 6 2 6 0 2 2 3
A= 4
As expected, the (6,8)-entry of A (G) counts the
by0symmetry,
two paths between vertices v and v –
1 0
of counting 1 is true
the same 0 of the0 (8,6)-entry.
0 1While 6
0 0 0 0 1 0 0 0
is the n x n matrix whose (i,j)-entry counts the number of paths of length k or less between
vertices v and v .
i j
MATRICES AND MATRIX OPERATIONS 95 / 107
Graph theory
17 11 1320 111 1 0 010 1 0 0 4
3 162
17 112 13 11 10 4 16 2
3
61 0 1 0 1 0 0 07 611 18 13 17 4 9 11 67
6 7 6 7
11 18 1366610 1017 0 1 0 4
1 0 1
0 1 07
0 1 0
79
7
116 6
613 13 28 13 16 14 13 27
611 17 1318 4 9 11 67
7
A(G) = 6 7 4 6
60 1 0 1 0 0 0 17 A (G) = 610 4 164 15 4 10 07
7 (2)
13 13 286661 013 0 0 016 0 1 014 136 4 92 149 4 10 4 27
7 6 7
7
7 6 7
40 0 1 1 0 1 0 05 416 11 1311 10 4 17 25
11 17 130 018 0 0 1 4 0 0 0 9 112 66 2 6 0 2 2 3
A4 =
4
As expected, the (6,8)-entry of A (G) counts the two paths
between vertices v and v –
10 4 16the same4is true15
by symmetry, 4 10
of the (8,6)-entry. 0result
While this
6
of counting the number of paths between vertices in a graph, it can be extended to a similarly
4 9 14 9 4 10 4 2
interesting and logical corollary.
Corollary 2.1. Let G be a graph with adjacency matrix A and k be a positive integer. Then
16 11 13 11 10S = A4+ A +17 2
the sum S defined by
n
2 k
n ... + A (3)
2 6 2 6 0 2 2 3
is the n x n matrix whose (i,j)-entry counts the number of paths of length k or less between
vertices v and v .
i j
MATRICES AND MATRIX OPERATIONS 97 / 107
MatLab Constructing Matrix
CONSTRUCTING MATRIX
EXAMPLE 12.1
A = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
1 2 3 4
5 6 7 8
A=
9 10 11 12
13 14 15 16
1
Zero matrix: zeros(m, n)
2
Square zero matrix of order n : zeros(n)
3
Identity matrix of order n : eye(n)
1
Rank of the matrix A : r ank(A)
2
Transforming the matrix A to reduced row
echelon form: r r e f (A) (Reduced row echelon
form)
3
Addition of Matrices: A + B
4
Subtraction of Matrices : A − B
5
Matrix multiplication: A ∗ B
6
Power of matrices: Aˆn
7
Scalar Multiples: k ∗ A
8
Transpose of Matrices: A.0
1
Extracting the entry at the i −th row and the
j −column of the matrix A : A(i , j )
2
Extracting the main diagonal of the square matrix
A : d i ag (A)
3
Extracting the i −row of the matrix A : A(i , :)
4
Extracting the j −column of the matrix A : A(:, j )
1
Multiply the i −row through by a nonzero
constant k A(i , :) = A(i , :) ∗ k
2
Add a constant times one row to another:
A(i , :) = A(i , :) + A( j , :) ∗ k
3
Interchange 2 rows
A = A([the order of rows in A], :)
1 2 3 4
5 6 7 8
A=
9 10 11 12
13 14 15 16
If A([1 3 2 4], :) we obtain
1 2 3 4
9 10 11 12
5 6 7 8
13 14 15 16
>> B = [A I]
1 2 3 4 1 0 0 0
2 5 4 7 0 1 0 0
B =
3 7 8 12 0 0 1 0
4 8 14 19 0 0 0 1
>> C =rref(B) ⇒
1 0 0 0 10 7 −9 1
0 1 0 0 −2 −3 4 −1
0 0 1 0 1 −3 3 −1
0 0 0 1 −2 2 −2 1