MATLAB聚类分析源代码

clc
clear
x=[75.2 0.14 1.86 0.91 5.21;
75.15 0.16 2.11 0.74 4.93;
72.19 0.13 1.52 0.69 4.65;
72.35 0.13 1.37 0.83 4.87;
72.74 0.10 1.41 0.72 4.99;
73.29 0.033 1.07 0.17 3.15;
73.72 0.033 0.77 0.28 2.78;];
%%系统距离法共包含四种具体聚类方法,此处给你最大和最小距离法
Y = pdist(x,'cityblock');
%%最短距离法
Z1 = linkage(Y,'single');
subplot(1,2,1);
[H,T] = dendrogram(Z1,'colorthreshold','default')
set(H,'LineWidth',2)
grid on;title('最短距离法聚类图')
%%最长距离法
Z2 = linkage(Y,'complete');
subplot(1,2,2);
[H,T] = dendrogram(Z2,'colorthreshold','default')
set(H,'LineWidth',2)
grid on;title('最长距离法聚类图')

猜你喜欢

转载自blog.csdn.net/qq_29706435/article/details/82381053
今日推荐