MATLAB Answers

bala k

euclidean distance of two vectors,

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.

1 Answer

Jan Simon
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


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

dali elite
on 16 May 2013

thanks a lot

Jan Simon
on 17 May 2013

@dali elite: Setting a flag is thought for calling the admin, such that they delete improper messages like spam or rudeness.

Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!