This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Expand tree node




expand(parent) expands the nodes of a tree or tree node. If parent is a Tree object, then the top-level nodes display in an expanded state. If parent is a TreeNode object, then that node displays in an expanded state.


expand(parent,'all') expands all nodes of a tree or tree node.


collapse all

Create a tree that has three levels of nodes. By default, the nodes display in a collapsed state.

f = uifigure;
tree = uitree(f,'Position',[20 20 175 100]);
% First level nodes
category1 = uitreenode(tree,'Text','Runners');
category2 = uitreenode(tree,'Text','Cyclists');

% Second level nodes
equip1 = uitreenode(category1,'Text','Equipment');
equip2 = uitreenode(category2,'Text','Equipment');
% Third level nodes
shoes = uitreenode(equip1,'Text','Running Shoes');
bike = uitreenode(equip2,'Text','Bicycle');
helmet = uitreenode(equip2,'Text','Helmet');

Expand the top-level nodes.


Expand all the nodes in the tree.


Input Arguments

collapse all

Parent tree or node, specified as a Tree object or TreeNode object.

Introduced in R2017b