Main Content

dtree

DTREE constructor

    Description

    T = dtree(ord,d,x) returns a complete data tree (DTREE) T object of order ord and depth d. The data associated with the tree is x.

    example

    T = dtree(ord,d,x,u) sets the user data field of T.

    [T,nb] = dtree(___) returns the number of terminal nodes (leaves) of T.

    [___] = dtree(Name=Value) specifies options using one or more name-value arguments. For example, to specify a tree of depth 4, set depth to 4.

    Examples

    collapse all

    Create a tree of order 2 and depth 3.

    x = 1:10;
    t = dtree(2,3,x)
     
    Data Tree Object Structure     
    ===============================
    Size of initial data :[1  10]
    Order                :2
    Depth                :3
    Terminal nodes       :[7   8   9  10  11  12  13  14]
    ------------------------------------------
     
    

    Use nodejoin to recompose the second node.

    t = nodejoin(t,2)
     
    Data Tree Object Structure     
    ===============================
    Size of initial data :[1  10]
    Order                :2
    Depth                :3
    Terminal nodes       :[7   8   9  10   2]
    ------------------------------------------
     
    

    Input Arguments

    collapse all

    Order of the tree, specified as an integer greater than or equal to 2.

    Data Types: double

    Depth of the tree, specified as a nonnegative integer.

    Data Types: double

    Data, specified as a vector or matrix.

    Data Types: double

    User data to set in the ud field of T, specified as an array, cell array, or structure array.

    Example: t = dtree(2,3,[0 1],{1,"aa",rand(3,3)})

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: t = dtree(order=2,depth=3) specifies a tree of depth 3 and order 2.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example: t = dtree("order",2,"depth",3) specifies a tree of depth 3 and order 2.

    Order of the tree, specified as an integer greater than or equal to 2.

    Depth of the tree, specified as nonnegative integer.

    Data associated to the tree, specified as a vector or matrix.

    Split scheme for nodes, specified as an ord-by-1 logical array.

    The root of the tree can be split and it has ord children. If spsch(j) = 1, you can split the jth child. Each node that you can split has the same property as the root node.

    User data to set in the ud field of T, specified as an array, cell array, or structure array.

    Output Arguments

    collapse all

    Tree, returned as a DTREE object. The tree has these fields:

    dtree

    Parent object

    allNI

    All nodes information

    terNI

    Terminal nodes information

    For more information on object fields, type:

    help dtree/get
    

    Number of terminal nodes (leaves) of T.

    Data Types: double

    Version History

    Introduced before R2006a

    See Also

    |