📄 som_dmatminima.m
字号:
function minima = som_dmatminima(sM,U,Ne)%SOM_DMATMINIMA Find clusters based on local minima of U-matrix.%% minima = som_dmatminima(sM,[U],[Ne])%% Input and output arguments ([]'s are optional):% sM (struct) map struct% U (matrix) the distance matrix from which minima is% searched from % size msize(1) x ... x msize(end) or % 2*msize(1)-1 x 2*msize(2)-1 or % munits x 1% Ne (matrix) neighborhood connections matrix%% minima (vector) indeces of the map units where locla minima of% of U-matrix (or other distance matrix occured)% % See also KMEANS_CLUSTERS, SOM_CLLINKAGE, SOM_CLSTRUCT.% Copyright (c) 2000 by Juha Vesanto% Contributed to SOM Toolbox on June 16th, 2000 by Juha Vesanto% http://www.cis.hut.fi/projects/somtoolbox/ % Version 2.0beta juuso 220800%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% map if isstruct(sM), switch sM.type, case 'som_map', M = sM.codebook; mask = sM.mask; case 'som_data', M = sM.data; mask = ones(size(M,2),1); endelse M = sM; mask = ones(size(M,2),1);end[munits dim] = size(M);% distances between map unitsif nargin<2, U = []; end% neighborhoods if nargin<3, Ne = som_neighbors(sM); end% distance matrixif nargin<2 | isempty(U), U = som_dmat(sM,Ne,'median'); endif prod(size(U))>munits, U = U(1:2:size(U,1),1:2:size(U,2)); endU = U(:); if length(U) ~= munits, error('Distance matrix has incorrect size.'); end% find local minimaminima = []; for i=1:munits, ne = find(Ne(i,:)); if all(U(i)<=U(ne)) & ~anycommon(ne,minima), minima(end+1)=i; endendreturn; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function t = anycommon(i1,i2) if isempty(i1) | isempty(i2), t = 0; else m = max(max(i1),max(i2)); t = any(sparse(i1,1,1,m,1) & sparse(i2,1,1,m,1)); end return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -