hi, i used this function kmeans, and take simple example
x=[100 2 4 10 200; 50 100 20 1 5];
what i got:
100 2 4 10 200
50 100 20 1 5
what i need is know each point for which cluster belong, what the code do is just get the two clusters i gave it and the points that i gave it.
how I know the clusters that each point belong to?
No products are associated with this question.
Huda, you gave kmeans two points and asked it to cluster them into two clusters. It has assigned the first point to cluster 1, whose centroid is at the first point, and similarly for the second point. Presumably that is not very informative.
I don't know what your data mean, or whether kmeans makes sense, but your description sounds like something more suited to distance-based methods such as hierarchical clustering or multidimensional scaling, both of which are available in the Statistics Toolbox. You would, of course, have to convert your similarities to dissimilarities.
The first output from kmeans() is the cluster number for each sample.
IDX = kmeans(X,k) partitions the points in the n-by-p data matrix X into k clusters. This iterative partitioning minimizes the sum, over all clusters, of the within-cluster sums of point-to-cluster-centroid distances. Rows of X correspond to points, columns correspond to variables. kmeans returns an n-by-1 vector IDX containing the cluster indices of each point. By default, kmeans uses squared Euclidean distances. When X is a vector, kmeans treats it as an n-by-1 data matrix, regardless of its orientation.