D = nodedesc(T,N)
D = nodedesc(T,N,'deppos')
nodedesc is a tree-management utility.
D = nodedesc(T,N) returns the indices of all the descendants of the node N in the tree T where N can be the index node or the depth and position of node. D is a column vector with D(1) = index of node N.
D = nodedesc(T,N,'deppos') is a matrix that contains the depths and positions of all descendants. D(i,1) is the depth of the i-th descendant and D(i,2) is the position of the i-th descendant.
The nodes are numbered from left to right and from top to bottom. The root index is 0.
% Create binary tree of depth 3. t = ntree(2,3); t = nodejoin(t,5); t = nodejoin(t,4); plot(t)
% Change Node Label from Depth_Position to Index % (see the plot function).
% Node descendants. nodedesc(t,2) ans = 2 5 6 13 14 nodedesc(t,2,'deppos') ans = 1 1 2 2 2 3 3 6 3 7 nodedesc(t,[1 1],'deppos') ans = 1 1 2 2 2 3 3 6 3 7 nodedesc(t,[1 1]) ans = 2 5 6 13 14