Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

getChildren

オブジェクトの子の特定

説明

objArray = getChildren(parent) は、指定された親をもつオブジェクトの配列を返します。

すべて折りたたむ

このチャートには、ステート A とデフォルト遷移の 2 つが子として含まれています。ステート A には、ステート A1、ステート A2、および 2 つの遷移の 4 つが子として含まれています。

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

モデルを開き、チャートの Stateflow.Chart オブジェクトにアクセスします。

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

チャートの子を特定します。子のオブジェクト タイプを表示します。

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

children の 1 つの要素はステートです。ステートの名前を表示します。

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

ステート A の子を特定します。子のオブジェクト タイプを表示します。

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

grandchildren の 2 つの要素はステートです。ステートの名前を表示します。

idx = (classes=="Stateflow.State");
grandchildren(idx).Name
ans = 
'A1'
ans = 
'A2'

入力引数

すべて折りたたむ

バージョン履歴

R2006a より前に導入