当前位置:文档之家› 用matlab实现聚类分析

用matlab实现聚类分析

用 Matlab 实现聚类分析

谱系聚类法步骤
寻找变量之间的相似性 Y=pdist(X)
定义变量之间的连接 Z=linkage(Y)
作出谱系聚类图 H=dendrogram(Z)创建聚类T=clus来自er(Z,’cutoff’,c)
Company name


创建聚类
T=cluster(Z,’cutoff’,c)
T是一个长度是M的矢量,表示每 一个测点所属的类别。 C is a threshold for cutting Z into clusters. 即代表距离门限值。
Company name

只用一个命令也可以搞定
T = clusterdata(X, cutoff) when 0 < cutoff < 2, clusterdata forms clusters when inconsistent values are greater than cutoff .(即代表距离门限) When cutoff is an integer and cutoff >= 2, then clusterdata interprets cutoff as the maximum number of clusters . (即代表所要分的类数)
Company name

定义变量之间的连接 Z=linkage(Y)
Z = linkage(Y,'method') ‘method’= 'single‘ Shortest distance (default) 'complete‘ Furthest distance ……………. Z is an (m-1)-by-3 matrix containing cluster tree information.
寻找变量之间的相似性 Y=pdist(X) X is a matrix of size M by N, treated as M observations of N variables. 每一行代 表一个站点,每一列代表一种参数值。 Y is a distance vector of length (M-1)*M/2-by-1 即假设数据点数长度为10,则Y是一个长度为 45的矢量。
T = clusterdata(X,'param1',val1,...)
Company name
Company name

作出谱系聚类图 H=dendrogram(Z)
2.5
2
1.5
1
0.5
0
18 26 1 4 16 19 24 22 23 20 21 28 8 9 14 29 30 6 7 10 11 12 13 15 17 2 3 5 25 27
Company name
相关主题