Shortest Distance between two vectors
49 次查看(过去 30 天)
显示 更早的评论
How can I find the shortest distnace between two vectors of same length?
is it like that
sqrt(vectorA+vectorB).
Thanks
0 个评论
回答(3 个)
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))
0 个评论
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 个评论
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
2018-2-20
What if the vectors are n1*n1*n3? Matlab function norm does not work in that case.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Directed Graphs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!