其他分享
首页 > 其他分享> > Matlab kmeans聚类

Matlab kmeans聚类

作者:互联网

Matlab kmeans聚类

rng('default') % For reproducibility
X = [randn(100,2)*0.75+ones(100,2);
    randn(100,2)*0.5-ones(100,2);
    randn(100,2)*0.75];

[idx,C] = kmeans(X,3);


figure(5);
gscatter(X(:,1),X(:,2),idx,'bgm')
hold on
plot(C(:,1),C(:,2),'kx')
legend('Cluster 1','Cluster 2','Cluster 3','Cluster Centroid')

 

 

 

 

参考:https://ww2.mathworks.cn/help/stats/kmeans.html

###########

标签:randn,kmeans,Cluster,ones,Matlab,聚类,100
来源: https://www.cnblogs.com/herd/p/14788455.html