Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

doubt regards to find the euclidean distance

Asked by ajith on 26 Jun 2013

using the kmeans to find the centroid matrix. the value of the centroid matrix is 2x419 kmeans clustered it into the 2 groups ie) 2x419= 1x419 is one group & another 1x419 is another group. Next step i give new 1x419 matrix to calculate which group is nearer. How to find which group is nearer?

0 Comments

ajith

1 Answer

Answer by Image Analyst on 26 Jun 2013

I'm not really sure what you mean by the centroid matrix. Do you have 419 (x,y) coordinates of centroids? Or do you have only 2 centroids? Are the 419 points actually data points, not centroids? Did you use k = 2 to cluster those 419 data points into 2 clusters, each with a centroid so that you have 2 centroids, not 419?

Assuming 2 clusters and 419 training points, you can find a generalized distance which is like a z score which is the number of standard deviations away from the centroid. So a "big" cluster would have more "pull" on determining which cluster an arbitrary point belonged to than a "small" compact cluster. So just calculate the centroid and average distance from the centroid for the two clusters. Then do it for your arbitrary point and figure out which generalized distance is lower - that's the cluster your point belongs to (should be assigned to).

1 Comment

ajith on 26 Jun 2013

sorry sir [idx,c,sumd,D]=kmeans(q,2); in that sumd is a centroid consists 3.69385e+09,7.4315e+09 are the centroid values sir, i give the new value 1x419 how to calculate the distance and centroid and also find which group it is...shall you explain in coding its most useful to understand me sir

Image Analyst

Contact us