The determinant of a K × K (square) matrix A = [amn] is defined by
where the minor Mkn is the determinant of the (K−1) × (K−1) (minor) matrix formed by removing the kth row and the nth column from A and ckn = (−1)k+nMkn is called the cofactor of akn.
Especially, the determinants of a 2 × 2 matrix A2×2 and a 3 × 3 matrix A3×3 are
Note the following properties.
The inverse matrix of a K × K (square) matrix A = [amn] is denoted by A−1 and defined to be a matrix which is pre‐multiplied/post‐multiplied by A to form an identity matrix i.e. satisfies
An element of the inverse matrix A−1=[αmn] can be computed as
where Mnm is the minor of anm and cmn = (‐1)m+nMnm is the cofactor of amn.
Note that a square matrix A is invertible/nonsingular if and only if
Let us consider the following set of linear equations in three unknown variables x1, x2, and x3:
This can be formulated in the matrix‐vector form
so that it can be solved as
The following statements and their running results illustrate the powerful usage of MATLAB in dealing with matrices and vectors.
>>a= [-2 2 3] % a 1x3 matrix (row vector)
a = -2 2 3
>>b= [-2; 2; 3] % 3x1 matrix (column vector)
B = -2
2
3
>>b= a.' % transpose
>>A= [1 -1 2; 0 1 0; -1 5 1] % a 3x3 matrix
>>A(1,2) % will return -1
>>A(:,1) % will return the 1st column of the matrix A
ans = -1
0
-1
>>A(:,2:3) % will return the 2nd and 3rd columns of the matrix A
ans = -1 2
1 0
5 1
>>c= a*A % vector–matrix multiplication
C= -5 19 -1
>>A*b
ans = 2
2
15
>>A*a % not permissible for matrices with incompatible dimensions
??? Error using ==> mtimes
Inner matrix dimensions must agree
>>a*c' % Inner product : multiply a with the conjugate transpose of c
ans = 45
>>a.*c % (termwise) multiplication element by element
ans = 10 38 -3
>>a./c % (termwise) division element by element
ans = 0.4000 0.1053 -3.0000
>>det(A) % determinant of matrix A
ans = 3
>>inv(A) % inverse of matrix A
ans = 0.3333 3.6667 -0.6667
0 1.0000 0
0.3333 -1.3333 0.3333
>>[V,E]= eig(A) % eigenvector and eigenvalue of matrix A
V = 0.8165 0.8165 0.9759
0 0 0.1952
0 + 0.5774i 0 - 0.5774i 0.0976
E = 1.0000 + 1.4142i 0 0
0 1.0000 - 1.4142i 0
0 0 1.0000
>>I= eye(3) % a 3x3 identity matrix
>>O= zeros(size(I)) % a zero matrix of the same size as I
>>A= sym('[a b c; d e f]') % a matrix consisting of (non-numeric) symbols
A = [ a, b, c]
[ d, e, f]
>>B= [1 0; 0 1; 1 1]
B = 1 0
0 1
1 1
>>A*B
ans = [a+c, b+c]
[d+f, e+f]