주요 콘텐츠

getChildren

객체의 자식 식별

설명

objArray = getChildren(parent)는 지정된 부모가 있는 객체의 배열을 반환합니다.

예제

예제

모두 축소

이 차트에는 A 상태와 디폴트 천이라는 두 개의 자식이 있습니다. 상태 A에는 상태 A1, 상태 A2, 천이 2개로 구성된 네 개의 자식이 있습니다.

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 = 2×1 cell
    {'Stateflow.State'     }
    {'Stateflow.Transition'}

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의 두 요소는 상태입니다. 상태의 이름을 표시합니다.

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

입력 인수

모두 축소

버전 내역

R2006a 이전에 개발됨