File Exchange

image thumbnail

K-means algorithm demo

version (1.59 KB) by Mauricio Martinez-Garcia
A simple implementation of the kmeans algorithm


Updated 01 Jul 2016

View Version History

View License

The k-means algorithm is widely used in a number applications like speech processing and image compression.
This script implements the algorithm in a simple but general way. It performs four basic steps.
1. Define k arbitrary prototypes from the data samples.
2. Assign each sample to the nearest prototype.
3. Recalculate prototypes as arithmetic means.
4. If a prototype changes, repeat step (2).

Cite As

Mauricio Martinez-Garcia (2021). K-means algorithm demo (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

Mohamed Elmesiry


zhang yu

meisam yadolahzadeh


michael scheinfeild

azzeddine menasria


Gunawan rudi

MATLAB Release Compatibility
Created with R2006b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!