There are at least two ways to obtain the level of a node in a CLASSREGTREE using MATLAB 7.6 (R2008a).
The first is to view the tree and read the number of levels from the GUI:
load fisheriris;
t = classregtree(meas,species,'names',{'SL' 'SW' 'PL' 'PW'});
view(t)
The second method allows you to programmatically obtain the number of levels. There is a file attached: 'levelOf.m' which uses recursion to obtain the level of any node in the tree, where the root node is level 1, the children of the root are level 2 and so forth. To obtain the number of levels, call LEVELOF with the following syntax:
nodeindex = t.numnodes;
nodelevel = levelOf(t,nodeindex)
To retrieve the maximum pruning level, use:
Best Answer