MATLAB: The “view” method for TreeBagger has been changed starting in MATLAB 8.1 (R2013a).

compactregressiontreeStatistics and Machine Learning Toolboxtreebaggerview

Running the below code in R2013a and 2012b gives different result: 
 
x = (0:0.2:10)'; 
y = sin(x); 
tr = TreeBagger(10,x,y,'method','regression') 
view(tr.Trees{1}) 
 
The method "view" in R2012b produces a figure and displays a tree structure graphically. However, in R2013a it displays the tree in the Command Window in a text format, similar to how disp(tr.Trees{1}) worked in R2012b.
 
How can I view the tree structure graphically in MATLAB R2013a and later?

Best Answer

The syntax for the graphical behavior of "view" has been changed in MATLAB 8.1 (R2013a).  The syntax required to see the graphical behavior is as follows:
 
x = (0:0.2:10)'; 
y = sin(x); 
tr = TreeBagger(10,x,y,'method','regression') ;
view(tr.Trees{1},'mode','graph');
 
For more information on this new syntax you can execute the following command in the MATLAB Command Window:
 
help classreg.learning.regr.CompactRegressionTree/view