Shortest Distance between two vectors

16 ビュー (過去 30 日間)
Algorithms Analyst
Algorithms Analyst 2013 年 6 月 26 日
コメント済み: Jan 2021 年 6 月 10 日
How can I find the shortest distnace between two vectors of same length?
is it like that
sqrt(vectorA+vectorB).
Thanks

回答 (3 件)

Jan
Jan 2013 年 6 月 26 日
編集済み: Jan 2013 年 6 月 26 日
"Vectors" can be moved freely by definition, so all vectors might have the distance 0. Or 42.
Do you mean lines, which require on point and a direction vector as a definition? Or do you mean the distance between the points these vectors point to from the origin?
For the latter case:
sqrt(sum((vectorA - vectorB) .^ 2))

Roger Stafford
Roger Stafford 2013 年 6 月 26 日
If by "distance" you mean the Euclidean distance between the vectors considered as "points" in n-dimensional space, n being the number of elements in each vector, then it would be this:
norm(vectorA-vectorB)
  3 件のコメント
dror yemini
dror yemini 2021 年 6 月 10 日
but if vectors ar a n*2 and b m*b diffrent lengths
Jan
Jan 2021 年 6 月 10 日
@dror yemini: The comment is not clear.
n = 3;
m = 4;
b = 5;
x = rand(n, 2);
y = rand(m, b);
Now what do you want to calcultae?

サインインしてコメントする。


Shilpi Sunil Kumar
Shilpi Sunil Kumar 2018 年 2 月 20 日
What if the vectors are n1*n1*n3? Matlab function norm does not work in that case.

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by