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.


NTREE constructor


T = ntree(ORD,D)
T = ntree
T = ntree(2,0)
T = ntree(ORD)
T = ntree(ORD,0)
T = ntree(ORD,D,S)
T = ntree(ORD,D,S,U)


T = ntree(ORD,D) returns an NTREE object, which is a complete tree of order ORD and depth D.

T = ntree is equivalent to T = ntree(2,0).

T = ntree(ORD) is equivalent to T = ntree(ORD,0).

With T = ntree(ORD,D,S) you can set a “split scheme” for nodes. The split scheme field S is a logical array of size ORD by 1.

The root of the tree can be split and it has ORD children. You can split the j-th child if S(j) = 1.

Each node that you can split has the same property as the root node.

With T = ntree(ORD,D,S,U) you can, in addition, set a userdata field.

Inputs can be given in another way:

T = ntree('order',ORD,'depth',D,'spsch',S,'ud',U). For “missing” inputs the defaults are ORD = 2 and D = 0 , S = ones([1:ORD]) , U = {}.

[T,NB] = ntree( ... ) returns also the number of terminal nodes (leaves) of T.

For more information on object fields, type help ntree/get.

Class NTREE (Parent class: WTBO)



Parent object


Tree order


Tree depth


Split scheme for nodes


Column vector with terminal node indices


% Create binary tree (tree of order 2) of depth 3.
t2 = ntree(2,3);

% Plot tree t2.

% Create a quadtree (tree of order 4) of depth 2.
t4 = ntree(4,2,[1 1 0 1]);

% Plot tree t4.

% Split and merge some nodes using the gui
% generated by plot (see the plot function).
% The figure becomes:

See Also

Introduced before R2006a

Was this topic helpful?