PlotClusters(Data,I​DX,Centers,Colors)

This function plots clustering data, for example the one provided by kmeans, if the data is 2d or 3d

You are now following this Submission

This function takes clustering data and plots it, if the data is 2d or 3d. The inputs are:
An m-by-d matrix of data points, where d is the number of dimension and m the number of data points
An m-by-1 vector of indices that associate each data point with a cluster.
Optional inputs:
A c-by-d matrix with c cluster centers. If not given, the function calculates them.
A c-by-3 matrix of colors, as generated by the hsv command. The number of colors has to be no less than the number of clusters
Uses: plot/plot3
Note: this was only tested with version 2008a on Windows. Should work for all versions.

Cite As

Elad Kivelevitch (2026). PlotClusters(Data,IDX,Centers,Colors) (https://www.mathworks.com/matlabcentral/fileexchange/31710-plotclusters-data-idx-centers-colors), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
2.0.2.0

.

2.0.1.0

Smaller number of point in the example to show centers

2.0.0.0

Version 2 includes two main improvements:
1. Performance is improved per Arnobou's comment below.
2. Help improvements + added example of how to use the function.

1.0.0.0