Main Content

allnodes

    Description

    allnodes is a tree management utility that returns one of two node descriptions: either indices, or depths and positions.

    N = allnodes(T) returns the indices of all the nodes of the tree T.

    N = allnodes(T,"deppos") returns the depths and positions of all the nodes of the tree T.

    example

    Examples

    collapse all

    This example shows how to obtain the depth-position and linear indices of a wavelet packet tree.

    Load the noisy Doppler signal and obtain the wavelet packet decomposition down to the level 4 using the db2 wavelet.

    load noisdopp
    T = wpdec(noisdopp,4,"db2");

    Obtain the depth-position indices.

    DepthPosition = allnodes(T,"deppos");

    Obtain the corresponding linear indices.

    LinearIndices = allnodes(T);

    Display the correspondence in a table.

    table(DepthPosition,LinearIndices)
    ans=31×2 table
        DepthPosition    LinearIndices
        _____________    _____________
    
           0    0              0      
           1    0              1      
           1    1              2      
           2    0              3      
           2    1              4      
           2    2              5      
           2    3              6      
           3    0              7      
           3    1              8      
           3    2              9      
           3    3             10      
           3    4             11      
           3    5             12      
           3    6             13      
           3    7             14      
           4    0             15      
          ⋮
    
    

    Input Arguments

    collapse all

    Tree, specified as a ntree, dtree, or wptree object.

    Output Arguments

    collapse all

    Node description, returned as a column vector or matrix. The nodes are numbered from left to right and top to bottom. The root index is 0.

    • If N = allnodes(T), N is a K-by-1 column vector, where K is the number of nodes in the tree. N(i) is the index of the ith node.

    • If N = allnodes(T,"deppos"), N is a K-by-2 matrix. N(i,1) is the depth and N(i,2) is the position of the ith node.

    Version History

    Introduced before R2006a

    See Also

    | |