help
play

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


  1. Matlab tutorial and Linear Announcements Algebra Review • Today’s 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 the end of class. • Essential for geometry of points and lines. • But also, all math is linear algebra. • Text is on reserve in the CS library. • (ok slight exaggeration). • Powerpoint should be available by • Many slides today adapted from Octavia 10am class day. Camps, Penn State. Starting Matlab Help • help • For PCs, Matlab should be a program. • help command • For Sun’s: Eg ., help plus Numerical • Help on toolbar • demo Analysis and Visualization • Tutorial: http:// amath . colorado . edu / scico /tutorials / matlab / Matlab 6.1 Matlab interpreter Vectors = v ( x , x x ) , , • Many common functions: see help ops • Ordered set of 1 2 n numbers: (1,2,3,4) = n ∑ 2 v x • Example: ( x,y,z ) = i i 1 coordinates of pt in = If 1 , is a unit vecto r v v space. 1

  2. Indexing into vectors Vector Addition + w = + = + + ( , ) ( , ) ( , ) v x x y y x y x y 1 2 1 2 1 1 2 2 V+w v w Scalar Product Operations on vectors • sum = = ( , ) ( , ) • max, min, mean, sort, … a v a x x ax ax 1 2 1 2 • Pointwise : .^ av v Matrices Inner (dot) Product   a a a 11 12 1 m   Sum: a a a   = + v α 21 22 2 m C A B × × × =   n m n m n m A a a a = = + × . ( , ).( , ) . n m  31 32 3 m  v w x x y y x y x y w = + 1 2 1 2 1 1 2 2   c a b ij ij ij    a a a  1 2 n n nm A and B must have the same The inner product is a SCALAR! dimensions = = ⋅ α . ( , ).( , ) || || || || cos v w x x y y v w 1 2 1 2 = 0 ⇔ ⊥ . v w v w 2

  3. Matrices Matrices Product: Transpose: A and B must have × = C A B × = + = + T T T T ( ) × × C A A B A B × n p n m m p compatible dimensions n m m n m ∑ = c = = c a b a T T T ( AB ) B A ij ik kj ij ji ≠ = 1 A B B A k × × × × n n n n n n n n A T = If A A is symmetric   1 0 0   Identity Matrix:   0 1 0 = = = I IA AI A         0 0 1 Matrices Matrices Determinant: Inverse: A must be square A must be square − = − = 1 1 A A A A I   × × a a a a × n n n n × = = − n n n n 11 12 11 12 det   a a a a 11 22 21 12  a a  a a − 1 −     21 22 21 22 a a 1 a a = 11 12 22 12     − −     a a a a a a a a   21 22 11 22 21 12 21 11 a a a 11 12 13   a a a a a a = 22 23 − 21 23 + 21 22 det a a a a a a   21 22 23 11 12 13 a a a a a a   32 33 31 33 31 32   a a a 31 32 33 Indexing into matrices Euclidean transformations 3

  4. 2D Translation 2D Translation Equation P’ P’ t t = t y P ( x , y ) P P = y t ( t x t , ) y x t x = + + = + P ' ( , ) P t x t y t x y 2D Translation using Matrices Scaling P’ = P’ ( , ) P x y t t y P = ( , ) t t x t y y t P P   x t x x  +    x t 1 0 t   → x = x ⋅ '     P y   + y t 0 1 t       y y 1   Scaling Equation Rotation P’ = s.y P ( , ) P x y = P ' ( sx , sy ) P P’ = s ⋅ y ' P P x s.x       sx s 0 x → = ⋅ ' P             sy 0 s y S = ⋅ P ' S P 4

  5. Rotation Equations Degrees of Freedom    θ − θ    ' cos sin x x Counter - clockwise rotation by an angle θ =       θ θ  '   sin cos    y y    θ − θ    ' cos sin x x =       R is 2x2 4 elements P’ θ θ  '   sin cos    y y Y’ θ BUT! There is only 1 degree of freedom: θ P P' = y R.P The 4 elements must satisfy the following constraints: x X’ ⋅ = ⋅ = T T R R R R I = det( R ) 1 Stretching Equation Stretching = tilting and projecting = (with weak perspective) ( , ) P x y = ' ( , ) P s x s y   s P’     x y 0     s x s S y .y x  x 0  x → = ⋅ = ⋅ '  x   x  P   s   s   0 s y s             y y y 0   y s x s x   y y   P 0 1 → = ⋅ '  x   x  P   s y 0 s       y y y y S x S x .x = ⋅ P ' S P Linear Transformation Affine Transformation     a b x   x → ⋅ ' P           SVD   c d y a b tx → ⋅ '   P y θ θ   ϕ ϕ     0     sin cos s sin cos x = ⋅   c d ty  x          − θ θ − ϕ ϕ 0  cos sin  s  cos sin      y  1  y   s θ θ ϕ ϕ       sin cos sin cos  x 0  x = ⋅ s   s       − θ θ − ϕ ϕ  cos sin   cos sin    y y y     0 1 5

  6. Files Functions • Format: function o = test(x,y) • Name function and file the same. • Only first function in file is visible outside 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. 6

  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.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend