allnodes

Syntax

```N = allnodes(T) N = allnodes(T,'deppos') ```

Description

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

The nodes are numbered from left to right and from top to bottom. The root index is 0.

`N = allnodes(T)` returns the indices of all the nodes of the tree `T` in column vector `N`.

`N = allnodes(T,'deppos')` returns the depths and positions of all the nodes in matrix `N`.

`N(i,1)` is the depth and `N(i,2)` the position of the node `i`.

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 ⋮ ```

Version History

Introduced before R2006a