Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Различные символы и цифры, Study notes of Matlab skills

В данном тексте представлены различные символы и цифры, непонятное содержание. Может содержать ссылки на коды или специфические знаки для конкретных дисциплин.

Typology: Study notes

2021/2022

Uploaded on 09/27/2022

elmut
elmut 🇺🇸

4.6

(16)

285 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The Projection Matrix
David Arnold
Fall 1996
Abstract
In this activity you will use Matlab to project a set of vectors onto a
single vector.
Prerequisites.
Inner product
(
dot product
)
and orthogonal vectors.
1 The Inner Product
We begin with the denition of the inner product.
Denition 1
Let
K
and
L
be vectors from
4
n
. The
inner product
(
dot prod-
uct
)
of vectors
K
and
L
is dened by
K
¢
L
=
K
T
L
Example 2
If
K
=
·
1
7
¸
and
L
=
·
¡
4
2
¸
, then
K
¢
L
=
K
T
L
=
£
17
¤·
¡
4
2
¸
=10
Check this result in Matlab.
>> u=[1;7]
u=
1
7
>> v=[-4;2]
v=
-4
1
pf3
pf4
pf5

Partial preview of the text

Download Различные символы и цифры and more Study notes Matlab skills in PDF only on Docsity!

The Projection Matrix

David Arnold

Fall 1996

Abstract In this activity you will use Matlab to project a set of vectors onto a single vector. Prerequisites. Inner product (dot product) and orthogonal vectors.

1 The Inner Product

We begin with the de nition of the inner product.

De nition 1 Let u and v be vectors from Rn. The inner product (dot prod- uct) of vectors u and v is de ned by

u ¢ v = uT^ v

Example 2 If u =

and v =

, then

u ¢ v = uT^ v

=

Check this result in Matlab.

u=[1;7]

u =

1 7

v=[-4;2]

v =

2

u’*v

ans =

10

If u, v and w are vectors from Rn^ and c is any real number, then it is not di¢cult to show that each of the following properties are true:

² u ¢ v = v ¢ u

² u ¢ (v + w) = u ¢ v + u ¢ w

² (cu) ¢ v = u ¢ (cv) = c(u ¢ v)

² u ¢ u ¸ 0 and u ¢ u = 0 if and only if u = 0.

Finally, orthogonal (perpendicular) vectors are de ned as follows.

De nition 3 Let u and v be vectors from Rn. Vectors u and v are orthogonal if and only if u ¢ v = 0.

1.1 The Projection of One Vector Onto Another

Figure 1 shows the projection of vector u onto vector v.

u

projvu v Figure 1. The projection of u onto v.

In Figure 2, it is clear that the projection of u onto v is some scalar multiple of v; that is, projvu = cv.

(v’u)/(v’v)*v

ans =

  • 1

1.2 The Projection Matrix

Let’s rework formula (2). First, when you multiply a vector by a scalar, it doesn’t matter whether you position the scalar before or after the vector.

projv u =

v ¢ u v ¢ v

v

= v

v ¢ u v ¢ v

Next, use the transpose de nition of the inner product followed by the associa- tive property of multiplication. Remember, when performing the dot product, a scalar multiplier may be placed anywhere you wish.

projvu =

vT^ v

v(vT u)

=

vT^ v

(vvT^ )u

vvT vT^ v

u

The expression vvT^ is called an outer product (the transpose operator is outside the product versus its inside position in the inner product). If we de ne

P = vvT vT^ v

, then the projection formula becomes

projvu = P u, where P =

vvT vT^ v

:

The matrix P is called the projection matrix. You can project any vector onto the vector v by multiplying by the matrix P.

Example 5 Let u =

onto v =

and nd P , the matrix that will

project any matrix onto the vector v. Use the result to nd projv u.

First, nd the projection matrix.

P =

vvT vT^ v

¸T

¸T ·

Check this result in Matlab.

P=(vv’)/(v’v)

P =

0.8000 -0. -0.4000 0.

Use this result to nd the projection of u onto v.

projv u = P u

=

Check this last result in Matlab.

P*u

ans =

  • 1

Note that this is identical to the result in Example 4.

1.3 Projecting a Lot of Vectors onto a Single Vector

First, use Matlab to generate 100 random vectors and plot them. The following commands will produce an image similar to that in Figure 3.

U=8*rand(2,100)-4; x=U(1,:); y=U(2,:); plot(x,y,’o’)

(a) Create a matrix P which will project each of the 2 £ 1 vectors in matrix U onto the vector v =

(b) Use the matrix P to project each 2 £ 1 vector in matrix U onto the vector v. Plot the results in a second color. (c) Obtain a printout of your result.

  1. The column space of the projection matrix P is a line in the direction of the vector v.

(a) What is the dimension of the column space of P? Check your answer with the ATLAST distribution’s colbasis command. (b) What is the rank of P? Check your answer with Matlab’s rank command.

  1. If matrix P projects all vectors onto the vector v, what should the matrix P P do? Can you explain geometrically why the matrices P P and P are equal? Check this in Matlab.