Cluster the N x p matrix X into k clusters using the kmeans algorithm. It returns the cluster memberships for each data point in the N x 1 vector IDX and the K x p matrix of cluster means in C.
This function is in some ways less general than Matlab’s kmeans.m (for example it only uses euclidian distance), but it has some options that the Matlab version does not (for example, it has a notion of outliers and min-cluster size). It is also many times faster than matlab’s kmeans.
General kmeans help can be found in help for the matlab implementation of kmeans. Note that the although the names and conventions for this algorithm are taken from Matlab’s implementation, there are slight alterations (for example, IDX==-1 is used to indicate outliers).