# How to find the center of mass of each cluster

조회 수: 41(최근 30일)
Pedro Nunes 7 Feb 2021
Hi guys, I have an excel file 168x65, where I want to divide the data into 6 clusters, and then I need to find the center of mass for each of cluster. I have already used the kmeans function to divide the data into clusters, but I can´t find the center of mass of each cluster.
The information in the file is temperatures, and when I use the kmeans function in that way
[idx c]=kmeans(data(:),6);
the variable C stays with the average temperatures of each cluster, and not the position of the centroides of each cluster.
I need help

댓글을 달려면 로그인하십시오.

### 채택된 답변

From the above information I'm assuming that data is a matrix of size 168x65. So data(:) returns a new array of size 10920x1 (all elements concatenated to a single column vector) and you are performing kmeans clustering on this new array and not on the actual data matrix.
Hence the kmeans is performed on the 10920 data points with each data point having dimension 1 forming 6 clusters and hence the cluster centers will be of dimension 1 as well.
If you are looking for your cluster center to be of dimension 65 then use the kmeans function as follows:
[idx c]=kmeans(data,6);

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by