⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clusteradvance.m

📁 DNa聚类分析软件
💻 M
字号:
clc;clear
path(path,'c:\');
load demo.txt
figure(1);
eucD = pdist(demo,'euclidean');
clustTreeEuc = linkage(eucD,'average');
cophenet(clustTreeEuc,eucD)
[h,nodes] = dendrogram(clustTreeEuc,0);
title('euclidean');

figure(2);
cosD = pdist(demo,'cosine');
clustTreeCos = linkage(cosD,'average');
cophenet(clustTreeCos,cosD)
[h,nodes] = dendrogram(clustTreeCos,0);
title('cosine');

figure(3);
clustTreeCen = linkage(eucD,'centroid');
[h,nodes] = dendrogram(clustTreeCen,0);
title('centroid');

figure(4);
clustTreeWard = linkage(eucD,'ward');
[h,nodes] = dendrogram(clustTreeWard,0);
title('ward');

ptsymb = {'bs','r^','md','go','c+'};
figure(5)
hidx = cluster(clustTreeCos,'criterion','distance','cutoff',.08);
for i = 1:5
    clust = find(hidx==i);
    plot3(demo(clust,1),demo(clust,2),demo(clust,3),ptsymb{i});
    hold on
end
hold off
xlabel('A factor'); ylabel('G factor'); zlabel('C factor');
view(-137,10);
grid on

figure(6);
[cidx2,cmeans2] = kmeans(demo,4,'dist','sqeuclidean');
[silh2,h] = silhouette(demo,cidx2,'sqeuclidean');

lnsymb = {'b-','r-','m-'};
[cidxCos,cmeansCos] = kmeans(demo,2,'dist','cos');
names = {'SL','SW','PL','PW'};
meas0 = demo ./ repmat(sqrt(sum(demo.^2,2)),1,4);
ymin = min(min(meas0));
ymax = max(max(meas0));
for i = 1:2
    subplot(1,2,i); plot(meas0(cidxCos==i,:)',lnsymb{i});
    hold on; plot(cmeansCos(i,:)','k-','LineWidth',2); hold off;
    title(sprintf('Cluster %d',i));
    set(gca,'Xlim',[.9 4.1],'XTick',1:4,'XTickLabel',names,'YLim',[ymin ymax])
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -