assign patterns to clusters

6 views (last 30 days)
Hello,
Consider two vectors 1xm, namely vector1 and vector2 and three other ones of the same size, namely v1, v2 and v3.
I calclulate the distances (which don`t have to be the Euclidean),
d(vector1,v1)
d(vector1,v2)
d(vector1,v3)
and
d(vector2,v1)
d(vector2,v2)
d(vector2,v3)
How can I assign the vector1 and vector2 to a cluster with the minimum distance to v1, v2 or v3?
For example,
IF d(vector1,v2).le.d(vector1,v1) AND d(vector1,v2).le.d(vector1,v3) THEN assign vector1 to cluster 2.
I don`t mind doing it with "if-then" or "for-end" or any function.
Thank you.
Best,
Natasha

Accepted Answer

Walter Roberson
Walter Roberson on 2 Sep 2012
[mindist, minidx] = min([d(vector1,v1), d(vector1,v2), d(vector1,v3)], 2);
then minidx will be the cluster number.

More Answers (0)

Categories

Find more on Third-Party Cluster Configuration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!