资源简介
采用matlab为运行环境的kmeans聚类程序,分为两个m文件,配有pdf文档,对该方法方法进行介绍、
代码片段和文件信息
function d=DistMatrix(AB)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DISTMATRIX return distance matrix between point A=[x1 y1] and B=[x2 y2]
% Author: Kardi Teknomo Ph.D.
% see http://people.revoledu.com/kardi/
%
% Number of point in A and B are not necessarily the same.
% It can be use for distance-in-a-slice (Spacing) or distance-between-slice (Headway)
%
% A and B must contain two column
% first column is the X coordinates
% second column is the Y coordinates
% The distance matrix are distance between points in A as row
% and points in B as column.
% example: Spacing= dist(AA)
% Headway = dist(AB) with hA ~= hB or hA=hB
% A=[1 2; 3 4; 5 6]; B=[4 5; 6 2; 1 5; 5 8]
% dist(AB)= [ 4.24 5.00 3.00 7.21;
% 1.41 3.61 2.24 4.47;
% 1.41 4.12 4.12 2.00 ]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[hAwA]=size(A);
[hBwB]=size(B);
if hA==1& hB==1
d=sqrt(dot((A-B)(A-B)));
else
C=[ones(1hB);zeros(1hB)];
D=flipud(C);
E=[ones(1hA);zeros(1hA)];
F=flipud(E);
G=A*C;
H=A*D;
I=B*E;
J=B*F;
d=sqrt((G-I‘).^2+(H-J‘).^2);
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 575538 2001-09-05 18:26 kMean\kMeanClustering.bmp
......R 190 2004-06-24 16:13 kMean\MSSCCPRJ.SCC
文件 10003 2004-06-24 17:32 kMean\kmean.frm
文件 653 2004-06-24 16:16 kMean\KMean.vbp
文件 49 2004-06-24 17:32 kMean\KMean.vbw
文件 1301 2005-04-15 03:44 kMean\DistMatrix.m
文件 4434 2005-05-17 21:47 kMean\kMeansCluster.m
文件 135113 2007-07-20 18:44 kMean\K mean Clustering1.pdf
文件 6568 2010-07-19 20:02 kMean\kmeans.m
目录 0 2009-10-20 20:42 kMean
----------- --------- ---------- ----- ----
733849 10
评论
共有 条评论