Professional Documents
Culture Documents
Introduction to Matlab
Vectors
X2
[x 1 , x 2 ]
X1
z y-z
xn ]
xn
i =1 k
xi yi
More on Vectors
Euclidian norm or length x =
x, x =
x
i =1 n
2 i
If |x|=1 we say x is normalized or unit length xT y Angle between vectors x and y cos = x y y x x y x
cos = 0 xT y = 0 xy
cos = 1 xT y =| x || y |> 0
y
cos = 1 xT y = | x || y |< 0
x orthogonal to y
More on Vectors
Vectors x and y are orthonormal if they are orthogonal and |x|=|y|=1 Euclidian distance between vectors x and y
xy =
x
i =1 n
( xi y i )
x-y y
Matrices
n by m matrix A and its m by n transpose A
T
xn1 x n2 xnm
Matrix Product
AB = a11 a12 a13 an1 an2 an3 a1d and b11 b21 b31 bd1 b1m b2m b3m = bdm cij =C
cij = a i , b j
a i is row i of A b j is column j of B
Matrices
Rank of a matrix is the number of linearly independent rows (or equivalently columns) A square matrix is non-singular if its rank equal to the number of rows. If its rank is less than number of rows it is singular. 10 0 0 1 0 Identity matrix I = 00 AI=IA=A 00 1 1 2 9 5 T 2748 Matrix A is symmetric if A=A 9436 5864
Matrices
Matrix A is positive definite if xT Ax = Ai , j xi x j > 0
i,j
aii
Matrices
Inverse of a square matrix A is matrix A -1 s.t. AA = I
-1
If A is singular or not square, inverse does not exist. Pseudo-inverse A is defined T whenever A A is not singular (it is square) T -1 T A = (A A ) A -1 T T AA =(A A) AA=I
Matrices
Determinant of n by n matrix A is
det( A) =
n k =1
( 1)
k +i
aik det(Aik )
Where Aik obtained from A by removing the ith row and kth column Absolute value of determinant gives the volume of parallelepiped spanned by the matrix rows
1 2 n } a + a + ... + a 1 2 n
i [0 ,1] i
Linear Transformations
A linear transformation from vector space V to vector space U is a mapping which can be represented by a matrix M:
u = Mv
V U
M
Mv
If U and V have the same dimension, M is a square matrix In pattern recognition, often U has smaller dimensionality than V, i.e. transformation M is used to reduce the number of features. M v= u
Given n by n matrix A, and nonzero vector x. Suppose there is which satisfies Ax= x
x is called an eigenvector of A is called an eigenvalue of A Linear transformation A maps an eigenvector v in a simple way. Magnitude changes by , direction If > 0 If < 0
Av v v Av
MATLAB
Starting matlab
xterm -fn 12X24 matlab
Basic Navigation
quit more help general
Relational operators
==,&,|,~,xor help relop
Elementary functions help elfun Data types double Char Programming in Matlab .m files scripts function y=square(x) help lang Flow control if i== 1else end, if else if end for i=1:0.5:2 end while i == 1 end Return help lang Graphics help graphics help graph3d File I/O load,save fopen, fclose, fprintf, fscanf