dist2pdist.m

来自「Continuous Profile Models (CPM) Matlab T」· M 代码 · 共 24 行

M
24
字号
% function pDistance = dist2pDist(d)

%% converts a distance matrix into the form output
%% by pDist and required by linkage

%% "distances are arranged in the order of 
%% ((1,2),(1,3),..., (1,N), (2,3),...(2,N),.....(N-1,N)), 
%% i.e. the lower left triangle of the full
%%    N-by-N distance matrix in column order."

function pDistance = dist2pDist(d)

numRow = size(d,1);
pDistance = zeros(1,numRow*(numRow-1)/2);


nxt=1;
for ft=1:numRow    
    for sc=(ft+1):numRow
        pDistance(nxt)=d(ft,sc);
        nxt=nxt+1;
    end
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?