一、算法
1) Input: K, set of points:p1,...,pn
2) Place centroids c1,...,ck at random locations
3) Repeat:
--for each point pi:
find nearest centroid cj and assign the pi to cluster j
--for each cluster j=1,...,K:
new centroid cj = mean of all points that assigned to cluster j;
Stop when none of the cluster assignments change
二、实现效果
三、源码
%============== K_means ================
clear;
close all;
total_width = 100;
total_height