MATLAB 帮助中心
标识对象的子级
objArray = getChildren(parent)
objArray = getChildren(parent) 返回一个具有指定父级的对象数组。
objArray
parent
示例
全部折叠
此示例使用:
此图有两个子级,即状态 A 和默认转移。状态 A 有四个子级,即状态 A1、状态 A2 和两个转移。
A
A1
A2
打开模型并访问图的 Stateflow.Chart 对象。
Stateflow.Chart
open_system("sfHierarchyAPIExample") ch = find(sfroot,"-isa","Stateflow.Chart");
标识图的子级。显示子级的对象类型。
children = getChildren(ch); classes = arrayfun(@class,children,UniformOutput=false)
classes = 2×1 cell {'Stateflow.State' } {'Stateflow.Transition'}
children 中的一个元素是状态。显示该状态的名称。
children
idx = (classes=="Stateflow.State"); state = children(idx); state.Name
ans = 'A'
标识状态 A 的子级。显示子级的对象类型。
grandchildren = getChildren(state); classes = arrayfun(@class,grandchildren,UniformOutput=false)
classes = 4×1 cell {'Stateflow.State' } {'Stateflow.State' } {'Stateflow.Transition'} {'Stateflow.Transition'}
grandchildren 中的两个元素是状态。显示状态的名称。
grandchildren
idx = (classes=="Stateflow.State"); grandchildren(idx).Name
ans = 'A1'
ans = 'A2'
Stateflow.State
Stateflow.Box
Stateflow.Function
父对象,指定为以下类型之一的 Stateflow® API 对象:
Stateflow.EMChart
Stateflow.EMFunction
Stateflow.SimulinkBasedState
Stateflow.SLFunction
Stateflow.StateTransitionTableChart
Stateflow.TruthTable
Stateflow.TruthTableChart
在 R2006a 之前推出
find
getParent
arrayfun
class
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处