资源简介
层次聚类的matlab程序,数据来源为80个平面点坐标。

代码片段和文件信息
function HCA()
%UNtitleD2 Summary of this function goes here
% Detailed explanation goes here
clear;clc
DataSet = load(‘testSet.txt‘);
index_of_cluster = core(DataSet);
plot_points(DataSet index_of_cluster);
%X = DataSet;
%Y = pdist(X‘cityblock‘);
%Z = linkage(Y‘average‘);
%[HT] = dendrogram(Z‘colorthreshold‘‘default‘);
%set(H‘LineWidth‘2)
end
function index_of_cluster = core(DataSet)
DS_size = size(DataSet);
min_distance = +inf;min_index = zeros(12);
index_of_cluster = 1:DS_size(1);
unique_index = unique(index_of_cluster);
size_unique = size(unique_index);
while(size_unique(2)>4)
for i=unique_index
for j=unique_index(unique_index > i)
temp_distance = distance_in_clusters(DataSet(index_of_cluster==i:) DataSet(index_of_cluster==j:)); %error.
if(temp_distance min_distance = temp_distance;
min_index = [ij];
end
end
end
min_distance = +inf;
index_of_cluster(index_of_cluster == min_index(2)) = min_index(1);
unique_index = unique(index_of_cluster);
size_unique = size(unique_index);
end
end
function distance = distance_in_clusters(clusterA clusterB)
% define the distance between two clusters: average-linkage(The mean distance between elements of each cluster).
A_size = size(clusterA);B_size = size(clusterB);
distance_AB = zeros(A_size(1) B_size(1));
for i=1:A_size(1)
for j=1:B_size(1)
distance_AB(ij) = distance_in_points(clusterA(i:) clusterB(j:));
end
end
distance = sum(sum(distance_AB))/(A_size(1)*B_size(1));
end
function dist = distance_in_points(vec1 vec2)
dist = sqrt(sum((vec1-vec2).^2));
end
function plot_points(DataSet index_of_cluster)
unique_index = unique(index_of_cluster);
point_type = ‘mxkxbxrxcxgxyx‘;
j = 1;
for i=unique_index
points = DataSet(index_of_cluster==i:);
plot(points(:1) points(:2)point_type((2*j-1):(2*j)))
j = j+1;
hold on
end
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2043 2015-12-15 20:13 Hierarchical clustering\HCA.asv
文件 2035 2015-12-15 20:33 Hierarchical clustering\HCA.m
文件 619 2015-12-15 11:43 Hierarchical clustering\distance_in_clusters.asv
文件 1600 2011-03-15 13:03 Hierarchical clustering\testSet.txt
文件 236278 2015-12-15 20:29 Hierarchical clustering\unti
目录 0 2015-12-15 20:35 Hierarchical clustering\
相关资源
- 组合导航matlab程序
- 替代数据法的matlab程序
- 神经网络分类matlab程序
- matlab程序用Hopfield网络解决TSP
- 多用户检测MATLAB程序
- 实现2ask.4ask.2fsk.4fsk.qam16.qam8调制的m
- 曲线旋转得到曲面的MATLAB程序
- 主动轮廓模型算法matlab程序
- Lozi混沌系统相关分析的MATLAB程序
- 用蚁群算法求解TSP问题的matlab程序
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- KF+EKF matlab程序实现
- 圆拟合matlab程序,以及圆心 半径的确
- stlwritematlab程序
- 层次分析法的matlab程序
- 泊松过程的模拟及检验 matlab程序
- 世上最牛的23个图像跟踪算法MATLAB程序
- 散点拟合平面的MATLAB程序
- 信号检测与估计-理论与应用答案及
- ROC曲线MATLAB程序
- dijkstra算法改进的matlab程序能求出两点
- EEMD的MATLAB程序
- 基于遗传算法的机器人路径规划matl
- 基于自适应压扩法降低OFDM系统的峰均
- 求露点温度matlab程序
- 计算图像Spatial Frequence的Matlab程序SF
- 德州扑克获胜概率计算的MATLAB程序
- 数模美赛常用模型算法matlab程序包+数
- 遗传算法完整MATLAB程序实数法,轮盘
评论
共有 条评论