Shortest Distance between two vectors

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일

0 개 추천

"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일

0 개 추천

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

Algorithms Analyst
Algorithms Analyst 2013년 6월 26일
I need to fine the minimum distance between two images let say I have two image
img1 and img2
then mindist(img1,img2) can be like sqrt(img.^2+img.^2);???
There is no lines so I need to find the minimum distance thats why I am confsed for its computation which distance is this?
dror yemini
dror yemini 2021년 6월 10일
but if vectors ar a n*2 and b m*b diffrent lengths
@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일

0 개 추천

What if the vectors are n1*n1*n3? Matlab function norm does not work in that case.

카테고리

도움말 센터File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

질문:

2013년 6월 26일

댓글:

Jan
2021년 6월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by