Help help For PCs, Matlab should be a program. help command For - - PDF document

help
SMART_READER_LITE
LIVE PREVIEW

Help help For PCs, Matlab should be a program. help command For - - PDF document

Matlab tutorial and Linear Announcements Algebra Review Todays goals: Class mailing list: send email to Learn enough matlab to get started. Hyoungjune Yi: aster@cs .umd.edu Review some basics of Linear Algebra Homework at


slide-1
SLIDE 1

1

Announcements

  • Class mailing list: send email to

Hyoungjune Yi: aster@cs.umd.edu

  • Homework at the end of class.
  • Text is on reserve in the CS library.
  • Powerpoint should be available by

10am class day.

Matlab tutorial and Linear Algebra Review

  • Today’s goals:
  • Learn enough matlab to get started.
  • Review some basics of Linear Algebra
  • Essential for geometry of points and lines.
  • But also, all math is linear algebra.
  • (ok slight exaggeration).
  • Many slides today adapted from Octavia

Camps, Penn State.

Starting Matlab

  • For PCs, Matlab should be a program.
  • For Sun’s:

Numerical Analysis and Visualization Matlab 6.1

Help

  • help
  • help command

Eg., help plus

  • Help on toolbar
  • demo
  • Tutorial:

http://amath.colorado.edu/scico/tutorials /matlab/

Matlab interpreter

  • Many common functions: see help ops

Vectors

  • Ordered set of

numbers: (1,2,3,4)

  • Example: (x,y,z)

coordinates of pt in space.

r unit vecto a is , 1 If ) , (

1 2 , , 2 1

v v x v x x x v

n i i n

= = =

=

slide-2
SLIDE 2

2

Indexing into vectors Vector Addition

) , ( ) , ( ) , (

2 2 1 1 2 1 2 1

y x y x y y x x + + = + = + w v

v w V+w

Scalar Product

) , ( ) , (

2 1 2 1

ax ax x x a a = = v

v av

Operations on vectors

  • sum
  • max, min, mean, sort, …
  • Pointwise: .^

Inner (dot) Product

v w α

2 2 1 1 2 1 2 1

. ) , ).( , ( . y x y x y y x x w v + = =

The inner product is a SCALAR!

α cos || || || || ) , ).( , ( .

2 1 2 1

w v y y x x w v ⋅ = = w v w v ⊥ ⇔ = 0 .

Matrices

                =

× nm n n m m m m n

a a a a a a a a a a a a A

2 1 3 32 31 2 22 21 1 12 11

m n m n m n

B A C

× × ×

+ =

Sum:

ij ij ij

b a c + =

A and B must have the same dimensions

slide-3
SLIDE 3

3

Matrices

p m m n p n

B A C

× × × =

Product:

=

=

m k kj ik ij

b a c

1

A and B must have compatible dimensions

n n n n n n n n

A B B A

× × × ×

Identity Matrix:

A AI IA I = =               = 1 1 1

Matrices

m n T n m

A C

× × =

Transpose:

ji ij

a c =

T T T

A B AB = ) (

T T T

B A B A + = + ) (

If

A AT =

A is symmetric

Matrices

Determinant: A must be square

32 31 22 21 13 33 31 23 21 12 33 32 23 22 11 33 32 31 23 22 21 13 12 11

det a a a a a a a a a a a a a a a a a a a a a a a a + − =          

12 21 22 11 22 21 12 11 22 21 12 11

det a a a a a a a a a a a a − = =      

Matrices

I A A A A

n n n n n n n n

= =

× × − × − × 1 1

Inverse: A must be square

      − − − =      

− 11 21 12 22 12 21 22 11 1 22 21 12 11

1 a a a a a a a a a a a a

Indexing into matrices Euclidean transformations

slide-4
SLIDE 4

4

2D Translation

t P

P’

2D Translation Equation

P x y t x t y

P’

t

t P P + = + + = ) , ( '

y x

t y t x ) , ( ) , (

y x t

t y x = = t P

2D Translation using Matrices

P x y t x t y

P’

t

) , ( ) , (

y x t

t y x = = t P           ⋅       =       + + → 1 1 1 ' y x t t t y t x

y x y x

P

t P

Scaling

P

P’

Scaling Equation

P x y s.x

P’

s.y

) , ( ' ) , ( sy sx y x = = P P

P P ⋅ = s '

      ⋅       =       → y x s s sy sx ' P S P S P ⋅ = '

Rotation

P

P’

slide-5
SLIDE 5

5

Rotation Equations

Counter-clockwise rotation by an angle θ

            − =       y x y x θ θ θ θ cos sin sin cos ' '

P x Y’

P’

θ X’ y

R.P P'=

Degrees of Freedom

R is 2x2 4 elements BUT! There is only 1 degree of freedom: θ

1 ) det( = = ⋅ = ⋅ R I R R R R

T T

The 4 elements must satisfy the following constraints:

            − =       y x y x θ θ θ θ cos sin sin cos ' '

Stretching Equation

P x y Sx.x

P’

Sy.y

      ⋅       =       → y x s s y s x s

y x y x

' P

) , ( ' ) , ( y s x s y x

y x

= = P P

S P S P ⋅ = '

Stretching = tilting and projecting (with weak perspective)

      ⋅           =       ⋅       =       → y x s s s y x s s y s x s

y x y y x y x

1 ' P

Linear Transformation

            − ⋅                 − =       ⋅       −             − =       ⋅       → y x s s s y x s s y x d c b a

y x y y x

ϕ ϕ ϕ ϕ θ θ θ θ ϕ ϕ ϕ ϕ θ θ θ θ sin cos cos sin 1 sin cos cos sin sin cos cos sin sin cos cos sin ' P

SVD

Affine Transformation

          ⋅       → 1 ' y x ty d c tx b a P

slide-6
SLIDE 6

6

Files Functions

  • Format: function o = test(x,y)
  • Name function and file the same.
  • Only first function in file is visible
  • utside the file.

Images Debugging

  • Add print statements to function by

leaving off ;

  • keyboard
  • debug and breakpoint

Conclusions

  • Quick tour of matlab, you should teach

yourself the rest. We’ll give hints in problem sets.

  • Linear algebra allows geometric

manipulation of points.

  • Learn to love SVD.
slide-7
SLIDE 7

This document was created with Win2PDF available at http://www.daneprairie.com. The unregistered version of Win2PDF is for evaluation or non-commercial use only.