length.m

来自「matlab数字信号处理工具箱」· M 代码 · 共 34 行

M
34
字号
function l = length(tree,r)
% XMLTREE/LENGTH Length Method
% FORMAT l = length(tree,r)
% 
% tree - XMLTree object
% r    - 'real' if present, returns the real number of nodes in the
%         tree (deleted nodes aren't populated)
% l    - length of the XML tree (number of nodes)
%_______________________________________________________________________
%
% Return the number of nodes of an XMLTree object.
%_______________________________________________________________________
% @(#)length.m                 Guillaume Flandin               02/03/27

error(nargchk(1,2,nargin));

% Return the full number of nodes once allocated
l = length(tree.tree);

% Substract the number of deleted nodes to the previous length
if nargin == 2
	if strcmp(r,'real')
		ll = 0;
		for i=1:l
			if ~strcmp(tree.tree{i}.type,'deleted')
				ll = ll + 1;
			end
		end
		l = ll;
	else
		error('[XMLTree] Bad input argument.');
	end
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?