MATLAB Answers

Euclidean distance of two vectors

2,744 views (last 30 days)
bala k
bala k on 9 Mar 2011
Commented: Jan on 15 Jul 2019
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 Comment

juit
juit on 23 Dec 2016
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???

Sign in to comment.

Accepted Answer

Jan
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

  10 Comments

Show 7 older comments
Jan
Jan on 14 Jul 2019
Concerning Rahul Ramkumar 's flag: "rude"
No, Rahul, this answer is not rude. I've posted 4 solutions and mentioned, that the OP can find an answer much faster by takine a look into the documentation. Many users are not familiatr with the docsearch command, although this is extremely useful and faster than waiting for an answer from the forum. It is worth to explain, that Matlab has some built-in tools to find solutions by your own.
Rik
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
Jan on 15 Jul 2019
Thanks, Rik. I've tried to elaborate my advice to search in the documentation before asking in the forum.

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by