Main Content

getParent

Identify parent of object

Description

parent = getParent(object) returns the parent of an object in a Stateflow® chart, State Transition Table, Truth Table, or MATLAB® Function block.

example

Examples

collapse all

In this chart, the parent of state A1 is state A. The parent of state A is the chart.

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.

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

Find the Stateflow.State object named A1.

sA1 = find(sfroot,"-isa","Stateflow.State",Name="A1");

Identify the parent of state A1. Display the name of the parent.

parent = getParent(sA1);
parent.Name
ans = 
'A'

Identify the parent of state A. Display the name of the parent.

grandparent = getParent(parent);
grandparent.Name
ans = 
'Chart'

Input Arguments

collapse all

Version History

Introduced before R2006a