k_means_(d, k, distance)

Version 1.1.0.0 (2.71 KB) by dangrewal
A k-means algorithm for clustering which automatically produces scatterplot of data as well.
1K Downloads
Updated 9 Jun 2016

View License

I have developed a k-means algorithm which accepts a maximum of 5 clusters. You can specify distance measure to use, i.e. 'euclidean', 'cosine' etc. and the function will also produce a scatter plot of your clustered data.
Please note:
- This is my first attempt at creating a k-means algorithm (created for university module work)
- It is by no means the fastest k-means algorithm available
- Uses random initialisation for initial centroids
- k_means_(d,k,distance)
- I have only tested it with a few types of data and have had great success, hopefully you won't have any problems
- If you are unfamiliar with this algorithm, please note that it requires a minimum of 2 dimensions for it to work.
- Use only numerical data i.e. ratio, interval. This algorithm is not suitable for categorical or ordinal data types.

Cite As

dangrewal (2024). k_means_(d, k, distance) (https://www.mathworks.com/matlabcentral/fileexchange/48476-k_means_-d-k-distance), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.0

Added note in description specifying that a minimum of 2 dimensions are needed
minor code update

1.0.0.0