Chapter 3
Chapter 3
If a matrix A is square, it can be multiplied by the identity matrix, I, from the left or from the right:
AI = IA = A
det(A)
The determinant of a square matrix can be calculated with the det command
Inverse of a matrix: The matrix B is the inverse of the matrix A if, when the
two matrices are multiplied, the product is the identity matrix.
Both matrices must be square and the multiplication order can be BA or AB:
BA = AB = I
Left division, \ :
Left division is used to solve the matrix equation AX = B. In this equation X and B are
column vectors. This equation can be solved by multiplying, on the left, both sides by the
inverse of A: X =A–1 B In MATLAB the last equation can be written by using the left
division character: X = A\B
The left division method is recommended for solving a set of linear equations
Solving three linear equations (array division) Use matrix operations to solve the following
system of linear equations
4x – 2y + 6z = 8
2x + 8y + 2z = 4
6x + 10y + 3z = 0
Equations can be written in the matrix
form AX=B
Right division, / :
The right division is used to solve the matrix equation XC = D In this equation X and D are
row vectors. This equation can be solved by multiplying, on the right, both sides by the
inverse of C: X .CC–1= D.C–1 which gives X=D.C-1 or X = D/C
Solving three linear equations (array division) Use matrix operations to solve the following system of
linear equations
4x – 2y + 6z = 8
Equations can be written in
2x + 8y + 2z = 4
the matrix form XC=D
6x + 10y + 3z = 0
ELEMENT-BY-ELEMENT OPERATIONS
Element-by-element multiplication, division, or exponentiation of two vectors or matrices
is entered in MATLAB by typing a period in front of the arithmetic operator.
Element-by-element operations can be done only with arrays of the same size.
BUILT-IN FUNCTIONS FOR ANALYZING ARRAYS
GENERATION OF RANDOM NUMBERS
The randn command generates normally distributed numbers with mean 0 and
standard deviation of 1. The command can be used to generate a single number,
a vector, or a matrix in the same way as the rand command. For example, a 3 x 4
matrix is created by:
Given the array A = 2 4 1 5
6726
3592
3) flipud(A)
4) fliplr(A)