Help CenterHelp Center
Identify parent of object
parent = getParent(object)
example
parent = getParent(object) returns the parent of an object in a Stateflow® chart, State Transition Table, Truth Table, or MATLAB® Function block.
parent
object
collapse all
This example uses:
In this chart, the parent of state A1 is state A. The parent of state A is the chart.
A1
A
Open the model and access the Stateflow.Chart object for the chart.
Stateflow.Chart
open_system("sfHierarchyAPIExample") ch = find(sfroot,"-isa","Stateflow.Chart");
Find the Stateflow.State object named A1.
Stateflow.State
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'
Stateflow.Box
Stateflow.Function
Object in a Stateflow chart, State Transition Table, Truth Table, or MATLAB Function block, specified as a Stateflow API object of one of these types:
Stateflow.Annotation
Stateflow.AtomicBox
Stateflow.AtomicSubchart
Stateflow.Data
Stateflow.EMFunction
Stateflow.Event
Stateflow.Junction
Stateflow.Message
Stateflow.Port
Stateflow.SimulinkBasedState
Stateflow.SLFunction
Stateflow.Transition
Stateflow.TruthTable
Introduced before R2006a
find
getChildren
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office