k-means algorithm
[counter] = kMeans(numPoints, numClusters, shape, drawOn, showOn)
This function takes as inputs: numPoints: the number of random points to cluster; numClusters: the number of clusters to group the points into; shape: a string 'square', 'circle', or 'tube' to carry out the kMeans process in; drawOn: a 1 or 0 indicating whether or not to show the points dynamically joining different clusters (not suitable for more than 500 points) ; showOn: a 1 or 0 indicating whether or not to show the update in clusters as a new figure after each iteration
Given the appropriate parameters kMeans first places k = numClusters random points in the given SHAPE and then carries out the kMeans algorithm. That is, we first assign each of the N = numPoints to the initial mean which is closest (in the standard Euclidean sense), then compute the centroid/center of mass of each cluster and then begin the reassignment process again.
Eventually, the algorithm will stabilize, and plots the final clusters as well as the path that the k means have followed.
Citar como
Tyler London (2026). k-means algorithm (https://la.mathworks.com/matlabcentral/fileexchange/26856-k-means-algorithm), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Compatibilidad con las plataformas
Windows macOS LinuxCategorías
Etiquetas
Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
| Versión | Publicado | Notas de la versión | |
|---|---|---|---|
| 1.0.0.0 |
