MATLAB 帮助中心
Node index to node depth-position
[d,p] = ind2depo(ord,n)
ind2depo is a tree-management utility.
ind2depo
[d,p] = ind2depo(ord,n) returns, for a tree of order ord, the depths d and positions p (at those depths) for the nodes with indices n.
d,p
ord
n
d
p
The nodes are numbered from left to right and from top to bottom. The root index is 0.
example
collapse all
Create a binary wavelet packet tree with three levels.
Ord = 2; Lev = 3; T = ntree(Ord,Lev);
Plot the tree.
plot(T)
Use the allnodes function to obtain the indices of the nodes in linear order.
allnodes
idx = allnodes(T);
Convert the indices to depth-position format.
[depth,pos] = ind2depo(Ord,idx); table(idx,depth,pos)
ans = 15×3 table idx depth pos ___ _____ ___ 0 0 0 1 1 0 2 1 1 3 2 0 4 2 1 5 2 2 6 2 3 7 3 0 8 3 1 9 3 2 10 3 3 11 3 4 12 3 5 13 3 6 14 3 7
Order of a tree, specified as a positive integer.
Example: A binary tree is a tree of order 2.
Node indices, specified as a column vector with nonnegative integer entries.
Depths and positions (at those depths) for the nodes with indices n, returned as a pair of column vectors with nonnegative integer entries.
The values of the depths D and positions N are such that 0≤D and 0≤ P ≤ ordD-1.
Note
If n is a M-by-2 matrix, we have ind2depo(ord,n) = [n(:,1),n(:,2)].
ind2depo(ord,n) = [n(:,1),n(:,2)]
expand all
backgroundPool
ThreadPool
The ind2depo function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
You can use ind2depo in thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
depo2ind
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 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处