Euclidean distance of two vectors

961 ビュー (過去 30 日間)
bala k
bala k 2011 年 3 月 9 日
コメント済み: Rik 2023 年 9 月 22 日
Euclidean distance of two vector. I have the two image values G=[1x72] and G1 = [1x72]. I need to calculate the two image distance value.
  1 件のコメント
juit
juit 2016 年 12 月 23 日
i have three points a(x1,y1) b(x2,y2) c(x3,y3) i have calculated euclidean distance d1 between a and b and euclidean distance d2 between b and c. if now i just want to travel through a path like from a to b and then b to c. can i add d1 and d2 to calculate total distance traveled by me???

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

採用された回答

Jan
Jan 2011 年 3 月 9 日
編集済み: Jan 2019 年 7 月 15 日
Do you know the definition of the Euclidean distance?
G = rand(1, 72);
G2 = rand(1, 72);
D = sqrt(sum((G - G2) .^ 2));
A more efficient method, but this matters only for much larger vectors:
V = G - G2;
D = sqrt(V * V');
Or a Matlab command:
D = norm(G - G2);
D = DNorm2(G - G2);
Searching in the documentation is faster than waiting for an answer in the forum. Therefore it is recommended to let Matlab search for the wanted keyword at first:
docsearch euclidean
  13 件のコメント
Dalia
Dalia 2023 年 9 月 21 日
what is the unit of D ?
Rik
Rik 2023 年 9 月 22 日
@Dalia it inherits the unit of the inputs. If those inputs are not the same units, you will have to fix that first.

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

その他の回答 (1 件)

Arash Azkia
Arash Azkia 2021 年 6 月 20 日
x = rand(n,1);
y = rand(n,1);
Distance = zeros(length(x) , length(y));
for i = 1:length(x)
for j = 1:length(y)
if i ~= j
Distance(i,j) = sqrt((x(i)-x(j))^2 + (y(i)-y(j))^2);
end
end
end

Community Treasure Hunt

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

Start Hunting!

Translated by