which point corresponds to which cluster in kemans function

hi to all.. i am using kmeans function for clustering.In that i am obtaining centroid locations. but i need which point corresponds to which cluster.because i need to fix the k value for the clustering.For that i need to calculate distance between each point and its corresponding cluster centroid......can anyone help me to find points corresponds to each cluster.

답변 (1개)

Tom Lane
Tom Lane 2012년 9월 12일
If you are using kmeans from the Statistics Toolbox, it sounds like the first output is what you want:
>> [a,b] = kmeans([0 0;0 .01; 1 1],2)
a =
2
2
1
b =
1.0000 1.0000
0 0.0050
This shows that the first two points correspond to cluster 2, with a centroid [0 .005], and the other point corresponds to cluster 1.
If you want to compute the distance between new points and the centroids, the pdist2 function might be useful.

카테고리

도움말 센터File Exchange에서 Cluster Analysis and Anomaly Detection에 대해 자세히 알아보기

질문:

2012년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by