matlab 进行均值聚类与分类
for i=1:1
clc
format long g
%均值聚类
opts = statset('Display','final');
[Idx,Ctrs,SumD,D] = kmeans(youjizhi,20,'Replicates',2000,'Options',opts, 'Start','uniform');
points=[Idx youjizhi];
%检验标准偏差分布
'全部样本的标准偏差'
wd=youjizhi';
std(wd,0,2)
'cluster样本差'
cluster1=[];
cluster2=[];
cluster3=[];
cluster4=[];
cluster5=[];
cluster6=[];
cluster7=[];
cluster8=[];
cluster9=[];
cluster10=[];
cluster11=[];
cluster12=[];
cluster13=[];
cluster14=[];
cluster15=[];
cluster16=[];
cluster17=[];
cluster18=[];
cluster19=[];
cluster20=[];
[row col]=size(points);
for i=1:1:row
id=points(i,1);
value=points(i,:);
if id==1
cluster1=[cluster1;value];
end
if id==2
cluster2=[cluster2;value];
end
if id==3
cluster3=[cluster3;value];
end
if id==4
cluster4=[cluster4;value];
end
if id==5
cluster5=[cluster5;value];
end
if id==6
cluster6=[cluster6;value];
end
if id==7
cluster7=[cluster7;value];
end
if id==8
cluster8=[cluster8;value];
end
if id==9
cluster9=[cluster9;value];
end
if id==10
cluster10=[cluster10;value];
end
if id==11
cluster11=[cluster11;value];
end
if id==12
cluster12=[cluster12;value]