Finding the projection on matlab

  • Thread starter Thread starter ver_mathstats
  • Start date Start date
  • Tags Tags
    Matlab Projection
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
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)