assign patterns to clusters

1 Ansicht (letzte 30 Tage)
Natasha Kratowska
Natasha Kratowska am 2 Sep. 2012
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

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Special Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by