Terminal nodes indices test
R = istnode(T,N)
istnode is a tree-management utility.
R = istnode(T,N) returns ranks (in left to right terminal nodes ordering) for terminal nodes N belonging to the tree T, and 0's for others.
N can be a column vector containing the indices of nodes or a matrix that contains the depths and positions of nodes.
In the last case, N(i,1) is the depth of the i-th node and N(i,2) is the position of the i-th node.
The nodes are numbered from left to right and from top to bottom. The root index is 0.
% Create initial tree. ord = 2; t = ntree(ord,3); % binary tree of depth 3. t = nodejoin(t,5); t = nodejoin(t,4); plot(t)
% Change Node Label from Depth_Position to Inde % (see the plot function)x.
% Find terminal nodes and return indices for terminal % nodes in the tree. istnode(t,) ans = 6 istnode(t,) ans = 0 istnode(t,[1;7;14;25]) ans = 0 1 6 0 istnode(t,[1 0;3 1;4 5]) ans = 0 2 0