Main Content

getChildren

Identify children of object

Description

example

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

Examples

collapse all

Suppose that ch is the Stateflow.Chart object that corresponds to this chart. 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.

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

children = getChildren(ch);
arrayfun(@class,children,UniformOutput=false)
ans =

  2×1 cell array

    {'Stateflow.State'     }
    {'Stateflow.Transition'}

The first element in children is a state. Display the name of the state.

state = children(1);
state.Name
ans =

    'A'

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

grandchildren = getChildren(state);
arrayfun(@class,grandchildren,UniformOutput=false)
ans =

  4×1 cell array

    {'Stateflow.State'     }
    {'Stateflow.State'     }
    {'Stateflow.Transition'}
    {'Stateflow.Transition'}

The first two elements in grandchildren are states. Display the names of the states.

grandchildren(1).Name
ans =

    'A1'
grandchildren(2).Name
ans =

    'A2'

Input Arguments

collapse all

Introduced before R2006a