Projection and distance of vectors - MATLAB

Hello,
I have two questions. For example I have two vectors u and v, and:
  1. I have to calculate the distance between vectors u and v
  2. I have to find the projection of u onto the line spanned by v
I have some ideas for the first one, dist(u-v) or just (u-v) but I am not sure if it is correct.
And for the second question I found the command in matlab that I could do it like this u=orth(v)
Can you please advise me if I am heading towards the right direction or am I completely clueless. :)
Thank you in advance Nina

 Accepted Answer

Matt J
Matt J on 8 Jan 2013
There is a function NORM for finding distances. There is also a function DOT for taking dot-products. As you know, dot-products play an important role in finding projections.

3 Comments

Matt, if you possibly still are active could you point me to where I can find out how to count projections? I've yet to see a helpful guide. Thanks!
@William I dont know what it means to "count projections". It probably warrants a separate question.
@Matt J Honestly that's all the instructions I recieved for that part. At least I know my confussion isn't just me being an airhead.

Sign in to comment.

More Answers (4)

Hi,
thank you for your prompt reply. Yes I know how to make dot product, but I don't know how to continue to get the projections. Do you maybe have any formula that I could use or at least if the above formulas are correct.
Thanks again Nina

1 Comment

if one "vector" goes from 2,2 to 3,3 and the other vector goes from 11,11 to 15,15, do those vectors have a projection? Or do all your vectors have their tails at the same location? Is the "distance" between the vectors, the distance between their tips?

Sign in to comment.

So maybe I wrote wrong the first time, the exercise I have is like this: Given the vectors u=[1.7;4.3;-1.6;2.7;1.8;4.1] and v [4.4;-2.2;3.3;1.9;0.6;-2.5] (in Matlab these vectors would be in one column each).
So like I wrote before, the task says:
1. calculate the distance between vectors u and v 2. calculate the projection of u onto the line spanned by v
So I am really lost at this, so any help would be appreciated.
Thank you once again Nina

1 Comment

You shouldn't still be lost now that you've been given the formulas and the code for the single vector case.

Sign in to comment.

Ops, didn't see those formulas. Thank you Roger!!!!!

1 Comment

It is strange that you have never seen these formulas in a class where the homework exercises so abundantly require them.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 8 Jan 2013

Commented:

on 7 Jul 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!