Top Banner
Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem sets in one zipped file to farrell (at) cs.umd.edu. When emailing matlab code to Ryan, use subject: CMSC 426 Matlab code.
21

Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Announcements

• Problem Set 2, handed out today, due next Tuesday.

• Late Homework should be turned into my office with date and time written on it.

• Mail problem sets in one zipped file to farrell (at) cs.umd.edu. When emailing matlab code to Ryan, use subject: CMSC 426 Matlab code.

Page 2: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

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.

Page 3: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Starting Matlab

• For PCs, Matlab should be a program.

• For Sun’s:

Numerical

Analysis and Visualization

Matlab 6.1

Page 4: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Help

• help• help commandEg., help plus• Help on toolbar• demo• Tutorial:

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

Page 5: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Matlab interpreter

• Many common functions: see help ops

Page 6: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Vectors

• Ordered set of numbers: (1,2,3,4)

• Example: (x,y,z) coordinates of pt in space. runit vecto a is ,1 If

),(

1

2

,,21

vv

xv

xxxvn

i i

n

Page 7: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Indexing into vectors

Page 8: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Vector Addition

),(),(),( 22112121 yxyxyyxx wv

vvww

V+wV+w

Page 9: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Scalar Product

),(),( 2121 axaxxxaa v

vv

avav

Page 10: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Operations on vectors

• sum

• max, min, mean, sort, …

• Pointwise: .^

Page 11: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Inner (dot) Product

vv

ww

22112121 .),).(,(. yxyxyyxxwv

The inner product is a The inner product is a SCALAR!SCALAR!

cos||||||||),).(,(. 2121 wvyyxxwv

wvwv 0.

Page 12: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

How do we prove these properties of the inner product? Let’s start with the fact that orthogonal vectors have 0 inner product. Suppose one vector is (x,y), and WLOG x,y>0. Then, if we rotate that by 90 degrees counterclockwise, we’ll get (y, -x). Rotating the vector is just like rotating the coordinate system in the opposite direction. And (x,y)*(y,-x) = xy – yx = 0.

Next, note that v*w = (v*w)/(||v||||w||) * ||v||||w|| This means that if we can show that when v and w are unit vectors v*w = cos alpha, then it will follow that in general v*w = ||v|| ||w|| cos alpha. So suppose v and w are unit vectors.

Next, note that if w1 + w2 = w, then v*w = v*(w1+w2) = v*w1 + v*w2. For any w, we can write it as the sum of w1+w2, where w1 is perpendicular to v, and w2 is in the same direction as v. So v*w1 = 0. v*w2 = ||w2||, since v*w2/||w2|| = 1. Then, if we just draw a picture, we can see that cos alpha = ||w2|| = v*w2 = v*w.

Page 13: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Matrices

nmnn

m

m

m

mn

aaa

aaa

aaa

aaa

A

21

33231

22221

11211

mnmnmn BAC Sum:Sum:

ijijij bac

A and B must have the same A and B must have the same dimensionsdimensions

Page 14: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Matrices

pmmnpn BAC Product:Product:

m

kkjikij bac

1

A and B must have A and B must have compatible dimensionscompatible dimensions

nnnnnnnn ABBA

Identity Matrix:

AAIIAI

100

010

001

Page 15: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Matrices

mnT

nm AC Transpose:Transpose:

jiij ac TTT ABAB )(

TTT BABA )(

IfIf AAT A is symmetricA is symmetric

Page 16: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Indexing into matrices

Page 17: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Files

Matlab

Page 18: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Functions

• Format: function o = test(x,y)

• Name function and file the same.

• Only first function in file is visible outside the file.

• Look at sample function

Page 19: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Images

• Black and white image is a 2D matrix.

• Intensities represented as pixels.

• Color images are 3D matrix, RBG.

• Matlab

Page 20: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Debugging

• Add print statements to function by leaving off ;

• keyboard

• debug and breakpoint

Page 21: Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.

Conclusions

• Quick tour of matlab, you should teach yourself the rest. We’ll give hints in problem sets.

• The inner product will be very important.