tree_stringrc.m

来自「Genetic Programming MATLAB Toolbox 遗传算」· M 代码 · 共 22 行

M
22
字号
function s = tree_stringrc(tree,ix,symbols)
%Decodes the tree to string
% s = tree_stringrc(tree,ix,symbols)
%   s <- the output string
%   tree -> the tree
%   ix -> index of strating point (the root = 1)
%   symbols -> cell arrays of operator and terminator node strings
% 
% Remark: It is a recursive function.
%

% (c) Janos Madar, University of Veszprem, 2005

if tree.nodetyp(ix)==1 & ix*2+1<=tree.maxsize,
  sleft = tree_stringrc(tree,ix*2,symbols);
  sright = tree_stringrc(tree,ix*2+1,symbols);
  s = strcat('(',sleft,')',symbols{tree.nodetyp(ix)}{tree.node(ix)}, ...
      '(',sright,')');
else
  s = symbols{tree.nodetyp(ix)}{tree.node(ix)};
end

⌨️ 快捷键说明

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