| 查看: 1215 | 回复: 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开始,不知道聚类为什么这样写,请赐教 |
» 猜你喜欢
祈祷自己至少3A2B上会啊!
已经有5人回复
航天502所 高瑛珂博士 婚内征婚 欺骗女性开房
已经有28人回复
山东省优青 青B通知了????
已经有3人回复
地球科学部D01口青年基金,最低几A几B几C才能有几率中呀。
已经有5人回复
26/27申博
已经有4人回复
博士申请
已经有5人回复











;
回复此楼