MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by bala k
on 9 Mar 2011

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.

*No products are associated with this question.*

Answer by Jan Simon
on 9 Mar 2011

Accepted answer

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);

A good ide is to search in the documentation before asking in MATLAB Answers:

docsearch euclidean

Show 1 older comment

Joel
on 13 Mar 2013

Do you currently have this project with you? I want to compare two vector which totals 27 feature vectors for each image.

Your reply is greatly appreciated

## 0 Comments