2,744 views (last 30 days)

Jan
on 9 Mar 2011

Edited: Jan
on 15 Jul 2019

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

Jan
on 14 Jul 2019

Rik
on 15 Jul 2019

This is about as rude as refering people to the FAQ: not very. It can sound a bit harsh, but it is valuable advice. You're getting free help from a stranger on the internet, that in itself is already friendly. You also need to account for the fact that for most people English is not their native language, and things may sound more rude to you than intended.

Because of these reasons I'm going to remove the flag. @Rahul Ramkumar, if you disagree, please post a comment with your reasoning. People on this forum are generally open to feedback and willing to edit their posts if good reasons are given.

Jan
on 15 Jul 2019

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/2849-euclidean-distance-of-two-vectors#comment_415890

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/2849-euclidean-distance-of-two-vectors#comment_415890

Sign in to comment.