Finding the projection on matlab

  • Thread starter Thread starter ver_mathstats
  • Start date Start date
  • Tags Tags
    Matlab Projection
Click For Summary
To find ||u − proj_v u|| for the vectors u = (3, -8, 5, 5) and v = (-9, -4, -7, 2), the projection of u onto v is calculated using the formula proj_v u = (dot(u,v) / norm(v)^2) * v, resulting in proj_v u = (1.2000, 0.5333, 0.9333, -0.2667). Subtracting this projection from u gives u1 = (1.8000, -8.5333, 4.0667, 5.2667). The dot product of u1 and proj_v u is approximately zero, indicating orthogonality. The discussion also suggests using the Gram-Schmidt process or QR factorization for further analysis.
ver_mathstats
Messages
258
Reaction score
21

Homework Statement



Let u = (3, -8, 5, 5) and v = (-9, -4, -7, 2). Find ||u − projvu||.

Homework Equations

The Attempt at a Solution


>> u=[3 -8 5 5]

u =

3 -8 5 5

>> v=[-9 -4 -7 2]

v =

-9 -4 -7 2

>> proj_u_v = dot(u,v)/norm(v)^2*v

proj_u_v =

1.2000 0.5333 0.9333 -0.2667

>> u1 = u - proj_u_v

u1 =

1.8000 -8.5333 4.0667 5.2667

>> dot(u1,proj_u_v)

ans =

2.2204e-16

This is what I have obtained so far, I'm not sure if I am looking for one value and how to obtain that one value?

Thank you.
 
Physics news on Phys.org
In terms of formatting, can you use the "plus" sign to insert code -> general code. It would make things a lot more legible. As for the openning line of your post, if you have the symbolic expression toolbox, MATLAB can create LaTeX for you e.g. see here:

https://www.mathworks.com/help/symbolic/latex.html
https://www.mathworks.com/matlabcen...it-possible-to-output-expressions-using-latex
- - - -
As for your post, the relevant equation here is Gramm Schmidt, right?

ver_mathstats said:
>> proj_u_v = dot(u,v)/norm(v)^2*v
This is close to Gramm Schmidt, but not quite right... why?

(Alternatively you could collect the vectors in matrix and run QR factorization if you're familiar with such a thing)
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
793
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K