assign patterns to clusters

1 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Special Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by