Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

istnode

Terminal nodes indices test

Syntax

R = istnode(T,N)

Description

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.

Examples

% 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,[14])
ans =
    6

istnode(t,[15])
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

See Also

|

Introduced before R2006a

Was this topic helpful?