| 查看: 1166 | 回复: 0 | ||
[求助]
matlab的聚类分析
|
|
n = 300 ; c = 3; t = randperm(n) ; x = [randn(1,n/3)-2 randn(1,n/3) randn(1,n/3)+2 ; randn(1,n/3) randn(1,n/3)+4 randn(1,n/3)]' ; m = x(t(1:c), ;x2 = sum(x.^2,2) ; s0(1:c,1)=inf; for o = 1 : 100 m2 = sum(m.^2,2) ; [d,y] = min(repmat(m2,1,n)+repmat(x2',c,1)-2*m*x') ; for j = 1 : c m(j, = mean(x(y==j, ) ;s(j,1) = mean(d(y==j)) ; end % norm(A) 返回矩阵A的二范数 % 矩阵的二范数 : A' * A 的最大特征值开平方 % A = [0 1 2 ; 3 4 5 ; 6 7 8] ; % norm(A) = sqrt(max(eig(A'*A))) = 14.2267 if norm(s-s0) < 0.001 break ; end s0 = s ; end figure(1) ;%创建图形窗口 clf ;%清除当前图像窗口 hold on ; plot(x(y==1,1),x(y==1,2),'bo') ; plot(x(y==2,1),x(y==2,2),'rx') ; plot(x(y==3,1),x(y==3,2),'gv') ; 本人初学者,有点看不懂,尤其是从for开始,不知道聚类为什么这样写,请赐教 |
» 猜你喜欢
论文终于录用啦!满足毕业条件了
已经有28人回复
假如你的研究生提出不合理要求
已经有4人回复
所感
已经有3人回复
要不要辞职读博?
已经有7人回复
不自信的我
已经有11人回复
北核录用
已经有3人回复
实验室接单子
已经有3人回复
磺酰氟产物,毕不了业了!
已经有8人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有10人回复
26申博(荧光探针方向,有机合成)
已经有4人回复












;
回复此楼