Code covered by the BSD License  

Highlights from
uidendrogram

uidendrogram

by

 

22 Aug 2010 (Updated )

Interactive dendrogram viewer using nested boxes

getleaves( link, id )
function out = getleaves( link, id )
%GETLEAVES - get the leaves of a linkage object
%   link - Nnodes x 3 object (returned from linkage function)
%   id - id of node for which to get leaves (not index into link)
%   out - logical vector of leaves.
    [m n] = size(link); 
    t = zeros(1, m+m+1);
    
    level = 1;
    flag = true;
    t(id) = 1;
    while(flag)
        flag = false;
        for ii = m+1+1:m+m+1
            if(t(ii) == level)
                t(link(ii-m-1, 1)) = level + 1;
                t(link(ii-m-1, 2)) = level + 1;
                flag = true;
            end
        end
        level = level + 1;
    end
    out = logical(t(1:m+1));
    
end

Contact us