MATLAB Help Center
Node index to node depth-position
[d,p] = ind2depo(ord,n)
ind2depo is a tree-management utility.
ind2depo
[d,p] = ind2depo(ord,n) returns, for a tree of order ord, the depths d and positions p (at those depths) for the nodes with indices n.
d,p
ord
n
d
p
The nodes are numbered from left to right and from top to bottom. The root index is 0.
example
collapse all
Create a binary wavelet packet tree with three levels.
Ord = 2; Lev = 3; T = ntree(Ord,Lev);
Plot the tree.
plot(T)
Use the allnodes function to obtain the indices of the nodes in linear order.
allnodes
idx = allnodes(T);
Convert the indices to depth-position format.
[depth,pos] = ind2depo(Ord,idx); table(idx,depth,pos)
ans = 15×3 table idx depth pos ___ _____ ___ 0 0 0 1 1 0 2 1 1 3 2 0 4 2 1 5 2 2 6 2 3 7 3 0 8 3 1 9 3 2 10 3 3 11 3 4 12 3 5 13 3 6 14 3 7
Order of a tree, specified as a positive integer.
Example: A binary tree is a tree of order 2.
Node indices, specified as a column vector with nonnegative integer entries.
Depths and positions (at those depths) for the nodes with indices n, returned as a pair of column vectors with nonnegative integer entries.
The values of the depths D and positions N are such that 0≤D and 0≤ P ≤ ordD-1.
Note
If n is a M-by-2 matrix, we have ind2depo(ord,n) = [n(:,1),n(:,2)].
ind2depo(ord,n) = [n(:,1),n(:,2)]
expand all
backgroundPool
ThreadPool
The ind2depo function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
You can use ind2depo in thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
depo2ind
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
Asia Pacific
Contact your local office