Docsity

Lecture 11: Linear Algebra and MATLAB®, Study notes of Linear Algebra

Partial preview of the text

Download Lecture 11: Linear Algebra and MATLAB® and more Study notes Linear Algebra in PDF only on Docsity!

Intelligent Sensor SystemsRicardo Gutierrez-OsunaWright State University

Lecture 11: Linear Algebra and MATLAB

g^

Vector and matrix notation

g^

Vectors

g^

Matrices

g^

Vector spaces

g^

Linear transformations

g^

Eigenvalues and eigenvectors

g^

MATLAB

®^

primer

Intelligent Sensor SystemsRicardo Gutierrez-OsunaWright State University

Vector and matrix notation g^

A d-dimensional (column) vector x and its transpose are written as:

g^

An n

× d (rectangular) matrix and its transpose are written as:

g^

The product of two matrices is

[^

]d

(^11)

T

1 2 d

x xx

x and x x x x^

L

M

nd

d 2 d 1

(^3) n

23 13

(^2) n

22 12

(^1) n

21 11 T

nd

(^3) n (^2) n (^1) n

d 2

23 22 21

d 1

13 12 11

a

a a

a

a a

a

a a

a

a a A and a

a a a

a

a a a

a

a a a A^

M O M M

L L L

M

O M M M

L L

=^ ∑=

d^1 k

kjik

ij

dd

(^3) d (^2) d (^1) d

d 3

33 32 31

d 2

23 22 21

d 1

13 12 11 dn

(^2) d (^1) d

n 3

32 31

n 2

22 21

n 1

12 11 nd

(^3) n (^2) n (^1) n

d 2

23 22 21

d 1

13 12 11

ba

c

where c

c c c

c

c c c

c

c c c

c c c c b b b

b

b b

b

b b

b b b a a a a

a

a a a

a

a a a AB

O M M M

L L L

O M M

L L L

O M M M

L L

Intelligent Sensor SystemsRicardo Gutierrez-OsunaWright State University

Matrices g^

The determinant of a square matrix A

d × d

is

n^

where A

is the minor matrix formed by removing the iik

th^ row and the k

th^ column of A

n^

NOTE: the determinant of a square matrix and its transpose is the same: |A|=|A

T |

g^

The trace of a square matrix A

d × d

is the sum of its diagonal elements

g^

The rank of a matrix is the number of linearly independent rows (or columns)

g^

A square matrix is said to be non-singular if and only if its rank equals the number of rows(or columns)

n^

A non-singular matrix has a non-zero determinant

g^

A square matrix is said to be orthonormal if AA

T =A

T A=I

g^

For a square matrix A

n^

if x

TAx>0 for all x

≠0, then A is said to be

positive-definite

(i.e., the covariance matrix)

n^

if x

TAx

≥0 for all x

≠0, then A is said to be

positive-semidefinite

g^

The inverse of a square matrix A is denoted by A

-1^ and is such that AA

-1 = A

-1 A=I

n^

The inverse A

-1^ of a matrix A exists

if and only if

A is non-singular

g^

The pseudo-inverse matrix A

†^ is typically used whenever A

-1^ does not exist (because A is

not square or A is singular):

ik ik d^1 k

ik^

A

a A^

=

=^ ∑

d =∑=^1 k

akk )A (tr

[^

]^

(^

singular- non is A A

assuming I AA with A A A A^

T

†

T 1 T †^

=^

−

Intelligent Sensor SystemsRicardo Gutierrez-OsunaWright State University

Vector spaces g^

The n-dimensional space in which all the n-dimensional vectorsreside is called a vector space

g^

A set of vectors {u

, u 1

, ... u 2

} is said to form a basis for a vectorn

space if any arbitrary vector x can be represented by a linearcombination of the {u

}i

n^

The coefficients {a

, a 1 , ... a 2

} are called the components of vector x with respectn

to the basis {u

}i

n^

In order to form a basis, it is necessary and sufficient that the {u

} vectors bei

linearly independent

g^

A basis {u

} is said to be orthogonal ifi

g^

A basis {u

} is said to be orthonormal ifi g As an example, the Cartesian coordinate base is an orthonormal base

g^

Given n linearly independent vectors {x

, x 1

, ... x 2

}, we can constructn

an orthonormal base {

φ ,^1

φ^

φ^

} for the vector space spanned byn

{xi

} with the Gram-Schmidt Orthonormalization Procedure

g^

The distance between two points in a vector space is defined as themagnitude of the vector difference between the points^ n

This is also called the Euclidean distance

nn

(^22) (^11)

ua

ua ua x^

L+

j i 0

j i 0 u u^ Tj i

=^

j i 0

j i 1 u u^ Tj i

u^3

u^2

u^1

u^3

a^1

a a 2 3

(^

)^

(^2) / 1

d^1 k

(^2) k k

E^

y x

y x )y, x( d^

^ 

=^

u^2

u^1

u^3

x

y

x-y

d(x,y)E^

Intelligent Sensor SystemsRicardo Gutierrez-OsunaWright State University

Eigenvectors and eigenvalues g^

Given a matrix A

N × N

, we say that v is an eigenvector* if there exists a scalar

(the eigenvalue) such that

g^

Computation of the eigenvalues

g^

The matrix formed by the column eigenvectors is called the modal matrix M

g^

Properties

n^

If A is non-singular

g^

All eigenvalues are non-zero

n^

If A is real and symmetric

g^

All eigenvalues are real g^

The eigenvectors associated with distinct eigenvalues are orthogonal

n^

If A is positive definite

g^

All eigenvalues will be positive

 ^ *The "eigen-" of "eigenvector" is normally translated as "characteristic" ⇔ =^

eigenvalue ing

correspond the is

r

eigenvecto an isv

Y Av

(^

)^

(^

(^

)^

(^44) (^44) 4

3

(^44) (^44) 4

2

1

L

Equationstic

Characteri

0 (^1) N (^1) N 1 N^

0 a a a 0 I A 0 I A

solution trivial non 0 I A

solution trivial

0 v 0 vI A 0 v Av v Av

= + + + ⇒ = − ⇒ = −



−

= = − ⇒ = − ⇒ = − ⇒ =

− −

N 2 1 N 3 2 1

v

v v v M^

O

L

Intelligent Sensor SystemsRicardo Gutierrez-OsunaWright State University

Interpretation of eigen-problems (1) g^

If we view matrix A as a linear transformation, an eigenvector represents aninvariant direction in the vector space

n^

When transformed by A, any point lying on the direction defined by v will remain on thatdirection, and its magnitude will be multiplied by the corresponding eigenvalue

n^

For example, the transformation which rotates 3-d vectors about the Z axis has vector [0 0 1]as its only eigenvector and 1 as the corresponding eigenvalue

x^1

x^2

v

P d

y^1

y^2

v

P d’=λd

P’

y=Ax

x

y

z

[^

T] (^10) 0 v^ =

   

^   

−

=

1

0 0

0

cos sin

0

sin

cos A

Intelligent Sensor SystemsRicardo Gutierrez-OsunaWright State University

MATLAB

®^

primer

g^

The MATLAB environment

n^

Starting and exiting MATLAB n^

Directory path n^

The startup.m file n^

The help command n^

The toolboxes

g^

Basic features (help general)

n^

Variables n^

Special variables (i, NaN, eps, realmax, realmin, pi,

…)

n^

Arithmetic, relational and logic operations n^

Comments and punctuation (the semicolon shorthand) n^

Math functions (help elfun)

g^

Arrays and matrices

n^

Array construction

g^

Manual construction g^

The 1:n shorthand g^

The linspace command

n^

Matrix construction

g^

Manual construction g^

Concatenating arrays and matrices

n^

Array and Matrix indexing (the colon shorthand) n^

Array and matrix operations

g^

Matrix and element-by-element operations

n^

Standard arrays and matrices (eye, ones and zeros) n^

Array and matrix size (size and length) n^

Character strings (help strfun)

g^

String generation g^

The str2mat function

g^

M-files

n^

Script files n^

Function files

g^

Flow control

n^

if..else..end construct n^

for construct n^

while construct n^

switch..case construct

g^

I/O (help iofun)

n^

Console I/O

g^

The fprintf and sprintf commands g^

the input command

n^

File I/O

g^

load and save commands g^

The fopen, fclose, fprintf and fscanf commands

g^

2D Graphics (help graph2d)

n^

The plot command n^

Customizing plots

g^

Line styles, markers and colors g^

Grids, axes and labels

n^

Multiple plots and subplots n^

Scatter-plots n^

The legend and zoom commands

g^

3D Graphics (help graph3d)

n^

Line plots n^

Mesh plots n^

image and imagesc commands n^

3D scatter plots n^

the rotate3d command

g^

Linear Algebra (help matfun)

n^

Sets of linear equations n^

The least-squares solution (x = A\b) n^

Eigenvalue problems

g^

Statistics and Probability

n^

Generation

g^

Random variables

n^

Gaussian distribution: N(0,1) and N(

μ,σ)

n^

Uniform distribution

g^

Random vectors

n^

correlated and uncorrelated variables

n^

Analysis

g^

Max, min and mean g^

Variance and Covariance g^

Histograms