%%kmeans聚类
function [minIndex] = my_kmeans(data,C_matrix,data_PCA)
%设置迭代次数
reps=10000;
for iter=1:reps
clf
%距离计算函数
%计算数据与各种中心点的距离
Dist_matrix=calcSqDistances(data,C_matrix);
%类别判断函数
%根据距离决定数据属于哪一类
minIndex=determineRnk(Dist_matrix);
new_C_matrix=C_matrix;
%画图函数
%画出当前数据聚类情况
plotCurrent(data_PCA,C_matrix,minIndex);
pause(1);
%更新质心点函数
%根据确定好的数据的类重新计算出新的中心点
C_matrix=recalcMus(data,minIndex);
%如果中心点的位置不再变化,则结束循环
if abs(new_C_matrix(:)-C_matrix(:))<1e-10
disp(iter);
break
end
end
end