Main Content


Identify children of object



objArray = getChildren(parent) returns an array of objects that have the specified parent.


collapse all

This chart has two children, state A and a default transition. State A has four children, state A1, state A2, and two transitions.

Stateflow chart with a hierarchy of states. The outer state is called A. It contains two inner states called A1 and A2.

Open the model and access the Stateflow.Chart object for the chart.

ch = find(sfroot,"-isa","Stateflow.Chart");

Identify the children of the chart. Display the object types of the children.

children = getChildren(ch);
classes = arrayfun(@class,children,UniformOutput=false)
classes = 2x1 cell
    {'Stateflow.State'     }

One element in children is a state. Display the name of the state.

idx = (classes=="Stateflow.State");
state = children(idx);
ans = 

Identify the children of state A. Display the object types of the children.

grandchildren = getChildren(state);
classes = arrayfun(@class,grandchildren,UniformOutput=false)
classes = 4x1 cell
    {'Stateflow.State'     }
    {'Stateflow.State'     }

Two elements in grandchildren are states. Display the names of the states.

idx = (classes=="Stateflow.State");
ans = 
ans = 

Input Arguments

collapse all

Version History

Introduced before R2006a