MATLAB Answers

How to find the center of mass of each cluster

조회 수: 41(최근 30일)
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

채택된 답변

Srivardhan Gadila
Srivardhan Gadila 14 Feb 2021
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);
For more information refer to colon, : & kmeans.
If this is not your issue, can you provide more information with relevant code and examples.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by