Introduction - If you have any usage issues, please Google them yourself
kmeans uses the k-means++ algorithm for centroid initialization and squared Euclidean distance by default. It is good practice to search for lower, local minima by setting the 'Replicates' name-value pair argument.
idx is a vector of predicted cluster indices corrresponding to the observations in X. C is a 3-by-2 matrix containing the final centroid locations.
Use kmeans to compute the distance from each centroid to points on a grid. To do this, pass the centroids (C) and points on a grid to kmeans, and implement one iteration of the algorithm.