I am having a problem in Matlab. I would like to use kmeans clustering and then get the value and index of the centroid. For example, if there is an $5*5$ array, we do kmeans clustering where k=2 and we get 2 centroids. How can I get these values for these centroids? I am currently working depth in matlab and would like to implement a research paper for this.
From the document: https://www.mathworks.com/help/stats/kmeans.html
idx = kmeans(X,k) idx = kmeans(X,k,Name,Value) [idx,C] = kmeans(___) [idx,C,sumd] = kmeans(___) [idx,C,sumd,D] = kmeans(___)
idx = kmeans(X,k) performs k-means clustering to partition the observations of the n-by-p data matrix X into k clusters, and returns an n-by-1 vector (idx) containing cluster indices of each observation. Rows of X correspond to points and columns correspond to variables.
By default, kmeans uses the squared Euclidean distance metric and the k-means++ algorithm for cluster center initialization.
[idx,C] = kmeans(___) returns the k cluster centroid locations in the k-by-p matrix C.
The code is:
[idx,C] = kmeans(X,3);