| 查看: 1223 | 回复: 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开始,不知道聚类为什么这样写,请赐教 |
» 猜你喜欢
评委有多少概率知道其他专家手中有哪些人的本子?
已经有4人回复
E0414, 我的本子有没有希望?
已经有17人回复
青A35岁以下通知答辩了吗
已经有4人回复
小城的小雨
已经有3人回复
看《给阿ma的情书》有感
已经有5人回复
国自然申请五篇代表作大比拼,感觉这个是最重要的
已经有4人回复
雷雨
已经有3人回复











;
回复此楼