The above matrix has four rows and three columns, so it is a 4 x 3 matrix.
A vector is a matrix with one column and many rows:
⎡⎣⎢⎢wxyz⎤⎦⎥⎥
[wxyz]
So vectors are a subset of matrices. The above vector is a 4 x 1 matrix.
Notation and terms:
A_{ij}Aijrefers to the element in the ith row and jth column of matrix A.
A vector with 'n' rows is referred to as an 'n'-dimensional vector
v_ivirefers to the element in the ith row of the vector.
In general, all our vectors and matrices will be 1-indexed. Note that for some programming languages, the arrays are 0-indexed.
Matrices are usually denoted by uppercase names while vectors are lowercase.
"Scalar" means that an object is a single value, not a vector or matrix.
\mathbb{R}Rrefers to the set of scalar real numbers
\mathbb{R^n}Rnrefers to the set of n-dimensional vectors of real numbers
Addition and Scalar Multiplication
Addition and subtraction areelement-wise, so you simply add or subtract each corresponding element:
In scalar multiplication, we simply multiply every element by the scalar value:To add or subtract two matrices, their dimensions must bethe same.
[acbd]
* x =
[a∗xc∗xb∗xd∗x]
[abcd]∗x=[a∗xb∗xc∗xd∗x]
Matrix-Vector Multiplication
We map the column of the vector onto each row of the matrix, multiplying each element and summing the result.
⎡⎣acebdf⎤⎦
*
[xy]
=
⎡⎣⎢a∗x+b∗yc∗x+d∗ye∗x+f∗y⎤⎦⎥
[abcdef]∗[xy]=[a∗x+b∗yc∗x+d∗ye∗x+f∗y]
The result is avector. The vector must be thesecondterm of the multiplication. The number ofcolumnsof the matrix must equal the number ofrowsof the vector.
Anm x n matrixmultiplied by ann x 1 vectorresults in anm x 1 vector.
Matrix-Matrix Multiplication
We multiply two matrices by breaking it into several vector multiplications and concatenating the result
Anm x n matrixmultiplied by ann x o matrixresults in anm x omatrix. In the above example, a 3 x 2 matrix times a 2 x 2 matrix resulted in a 3 x 2 matrix.
To multiply two matrices, the number ofcolumnsof the first matrix must equal the number ofrowsof the second matrix.
Matrix Multiplication Properties
Not commutative. A∗B≠B∗A
Associative. (A∗B)∗C=A∗(B∗C)
Theidentity matrix, when multiplied by any matrix of the same dimensions, results in the original matrix. It's just like multiplying numbers by 1. The identity matrix simply has 1's on the diagonal (upper left to lower right diagonal) and 0's elsewhere.
⎡⎣100010001⎤⎦
[100010001]
When multiplying the identity matrix after some matrix (A∗I), the square identity matrix should match the other matrix'scolumns. When multiplying the identity matrix before some other matrix (I∗A), the square identity matrix should match the other matrix'srows.
Inverse and Transpose
Theinverseof a matrix A is denoted A−1. Multiplying by the inverse results in the identity matrix.
A non square matrix does not have an inverse matrix. We can compute inverses of matrices in octave with the pinv(A) function [1] and in matlab with the inv(A) function. Matrices that don't have an inverse aresingularordegenerate.
Thetranspositionof a matrix is like rotating the matrix 90°in clockwise direction and then reversing it. We can compute transposition of matrices in matlab with the transpose(A) function or A':