mat lab tutorial and linear algebra review

35
7/23/2019 Mat Lab Tutorial and Linear Algebra Review http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 1/35   Announcements Class mailing list: send email to Hyoungjune Yi: [email protected] Homework at the end of class. Text is on resere in the C! li"rary. #ower$oint should "e aaila"le "y %&am class day.

Upload: animesh-sen

Post on 18-Feb-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 1/35

 

 Announcements

• Class mailing list: send email to

Hyoungjune Yi: [email protected]

• Homework at the end of class.

• Text is on resere in the C! li"rary.

• #ower$oint should "e aaila"le "y%&am class day.

Page 2: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 2/35

 

'atla" tutorial and (inear

 Alge"ra )eiew• Today*s goals:• (earn enough matla" to get started.

• )eiew some "asics of (inear Alge"ra• +ssential for geometry of $oints and lines.• ,ut also- all math is linear alge"ra.• ok slight exaggeration/.

• 'any slides today ada$ted from 0ctaiaCam$s- #enn !tate.

Page 3: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 3/35

 

!tarting 'atla"

• 1or #Cs- 'atla" should "e a $rogram.

• 1or !un*s:

2umerical

 Analysis and 3isuali4ation

'atla" 5.%

Page 4: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 4/35

 

Hel$

• hel$

• hel$ command

+g.- hel$ $lus

• Hel$ on tool"ar 

• demo

• Tutorial:htt$:66amath.colorado.edu6scico6tutorials6matla"6

Page 5: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 5/35

 

'atla" inter$reter 

• 'any common functions: see hel$ o$s

Page 6: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 6/35

 

3ectors

• 0rdered set of

num"ers: %-7-8-9/

• +xam$le:  x,y,z /coordinates of $t in

s$ace.  r unit vectoais,1If 

),(

1

2

,,21

vv

 xv

 x x xv

n

i   i

n

==

=

∑=

Page 7: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 7/35 

ndexing into ectors

Page 8: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 8/35

 

3ector Addition

),(),(),(22112121

  y x y x y y x x   ++=+=+wv

vvww

V+wV+w

Page 9: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 9/35

 

!calar #roduct

),(),(2121

  axax x xaa   ==v

vv

avav

Page 10: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 10/35

 

0$erations on ectors

• sum

• max- min- mean- sort- ;

•  #ointwise: .<

Page 11: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 11/35

 

nner dot/ #roduct

vv

ww

αα

22112121   .),).(,(.   y x y x y y x xwv   +==

The inner $roduct is aThe inner $roduct is a !CA(A)=!CA(A)=

α cos||||||||),).(,(. 2121   wv y y x xwv  ⋅==

wvwv   ⊥⇔= 0.

Page 12: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 12/35

 

'atrices

nmnn

m

m

m

mn

aaa

aaa

aaa

aaa

 A

21

33231

22221

11211

mnmnmn   B AC  ×××   +=Sum:Sum:

ijijij   bac   +=

 A and , must hae the same A and , must hae the same

dimensionsdimensions

Page 13: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 13/35

 

'atrices

 pmmn pn   B AC  ×××   =Product:Product:

∑==

m

kjik ij   bac1

 A and , must hae A and , must hae

com$ati"le dimensionscom$ati"le dimensions

nnnnnnnn   A B B A ××××   ≠

dentity 'atrix:

 A AI  IA I    ==

     

 

 

=

100

010

001

Page 14: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 14/35

 

'atrices

mnT 

nm   AC    ××   =Trans$ose:Trans$ose:

 jiij   ac   =   T T T   A B AB   =)(

T T T   B A B A   +=+   )(

f f    A AT  =  A is symmetric A is symmetric

Page 15: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 15/35

 

'atrices

Determinant:Determinant: A must be squareA must be square

3231

2221

13

3331

2321

12

3332

2322

11

333231

232221

131211

detaa

aaa

aa

aaa

aa

aaa

aaa

aaa

aaa

+−=

12212211

2221

1211

2221

1211det   aaaa

aa

aa

aa

aa−==

Page 16: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 16/35

 

'atrices

 I  A A A A nnnnnnnn   ==   ××−

×−

×11

nerse:nerse:  A must "e s>uare A must "e s>uare

−−

=

  −

1121

1222

12212211

1

2221

1211   1

aa

aa

aaaaaa

aa

Page 17: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 17/35

 

ndexing into matrices

Page 18: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 18/35

 

+uclidean transformations

Page 19: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 19/35

 

7? Translation

tt

PP

P’P’

Page 20: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 20/35

 

7? Translation +>uation

PP

xx

 y y

ttxx

tt y y

P’P’tt

tPP   +=++=   ),('  y x   t  yt  x

),(

),(

 y x   t t 

 y x

=

=

t

P

Page 21: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 21/35

 

7? Translation using 'atrices

PP

xx

 y y

ttxx

tt y y

P’P’tt

),(

),(

 y x

  t t 

 y x

=

=

t

P

=

+

+

→1

1

0

0

1

'   y

 x

t  y

t  x

 y

 x

 y

 x

P

tt PP

Page 22: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 22/35

 

!caling

PP

P’P’

Page 23: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 23/35

 

!caling +>uation

PP

xx

 y y

s.xs.x

P’P’s.ys.y

),('

),(

 sy sx

 y x

=

=

P

P

PP   ⋅= s'

=

→  y

 x

 s

 s

 sy

 sx

0

0

'P

SPSP   ⋅='

Page 24: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 24/35

 

)otation

PP

P’P’

Page 25: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 25/35

 

)otation +>uations

Counter-clocwise rotation by an an!leCounter-clocwise rotation by an an!le θθ

  −

=

 y

 x

 y

 x

θ θ 

θ θ 

cossin

sincos

'

'

PP

xx

"’"’P’P’

θθ

#’#’

 y y   R.PP'=

Page 26: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 26/35

 

?egrees of 1reedom

$ is %x%$ is %x% & elements& elements

'()* )ere is only , de!ree o reedom:'()* )ere is only , de!ree o reedom: θθ

1)det(   ==⋅=⋅

IR R R R   TT

)e & elements must satisy te ollowin! constraints:)e & elements must satisy te ollowin! constraints:

  −=

 y

 x

 y

 x

θ θ 

θ θ 

cossin

sincos

'

'

Page 27: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 27/35

 

!tretching +>uation

PP

xx

 y y

SSxx.x.x

P’P’SS y y.y.y

=

→ y

 x

 s

 s

 y s

 x s

 y

 x

 y

 x

0

0'P

),('),( y s x s

 y x

 y x==

P

P

S

PSP   ⋅='

Page 28: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 28/35

 

!tretching tilting and $rojecting

with weak $ers$ectie/

=

=

 y

 x s

 s

 s

 y

 x

 s

 s

 y s

 x s

 y

 x

 y y

 x

 y

 x

10

0

0

0'P

Page 29: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 29/35

 

(inear Transformation

=

=

 y

 x s

 s

 s

 y

 x

 s

 s

 y

 x

d c

ba

 y

 x

 y

 y

 x

ϕ ϕ 

ϕ ϕ 

θ θ 

θ θ 

ϕ ϕ 

ϕ ϕ 

θ θ 

θ θ 

sincos

cossin

10

0

sincos

cossin

sincos

cossin

0

0

sincos

cossin

'P!3?

Page 30: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 30/35

 

 Affine Transformation

→1

'   y

 x

tyd c

txba

P

Page 31: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 31/35

 

1iles

Page 32: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 32/35

 

1unctions

• 1ormat: function o testx-y/

• 2ame function and file the same.

• 0nly first function in file is isi"le

outside the file.

Page 33: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 33/35

 

mages

Page 34: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 34/35

 

?e"ugging

•  Add $rint statements to function "y

leaing off

• key"oard

• de"ug and "reak$oint

Page 35: Mat Lab Tutorial and Linear Algebra Review

7/23/2019 Mat Lab Tutorial and Linear Algebra Review

http://slidepdf.com/reader/full/mat-lab-tutorial-and-linear-algebra-review 35/35

Conclusions

• Buick tour of matla"- you should teach

yourself the rest. e*ll gie hints in

$ro"lem sets.• (inear alge"ra allows geometric

mani$ulation of $oints.

• (earn to loe !3?.