MATLAB 도움말 센터
Node descendants
D = nodedesc(T,n)
D = nodedesc(T,n,"deppos")
nodedesc is a tree-management utility.
nodedesc
D = nodedesc(T,n) returns the indices of all the descendants of the node n in the tree T.
D
T
n
example
D = nodedesc(T,n,"deppos") returns the depths and positions of all the descendants of the node n in the tree T.
collapse all
Create a binary tree of depth 3.
t = ntree(2,3);
Recompose two of the nodes. Plot the tree.
t = nodejoin(t,5); t = nodejoin(t,4); fig = plot(t);
Programmatically, in Node Label, change the selected item from Depth_Position to Index.
Depth_Position
Index
plot(t,"setNodeLabel",fig,"Index")
Obtain the indices of the descendants of the node whose index is 2.
nodedesc(t,2)
ans = 5×1 2 5 6 13 14
Obtain the depths and positions of the descendants of the same node.
nodedesc(t,2,"deppos")
ans = 5×2 1 1 2 2 2 3 3 6 3 7
Obtain the depths and positions of the descendants of the node at depth-position (1,0).
(1,0)
nodedesc(t,[1 0],"deppos")
ans = 5×2 1 0 2 0 2 1 3 0 3 1
Obtain the indices of the descendants of the same node.
nodedesc(t,[1 0])
ans = 5×1 1 3 4 7 8
dtree
ntree
wptree
Tree, specified as a dtree, ntree, or wptree object.
Tree node, specified as a nonnegative integer or a 1-by-2 vector. You can specify the node by either its index or depth and position.
Data Types: double
double
Descendants of the node n, returned as a column vector of node indices or a two-column matrix containing the depths and positions of the descendants.
If D is a vector, then D(1) is the index of the node n
D(1)
If D is a matrix, the ith row of D contains the depth and position of the ith descendant. The first row of D is the depth and position of the node n.
Introduced before R2006a
nodeasc | nodepar | wtreemgr
nodeasc
nodepar
wtreemgr
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 사이트 방문이 최적화되지 않았습니다.
미주
유럽
아시아 태평양
지역별 지사에 문의