Home > classes > @history > getNodes.m

getNodes

PURPOSE ^

GETNODES converts a history object to a nodes structure suitable for plotting as a tree.

SYNOPSIS ^

function [n,a,nodes] = getNodes(h, n, pn, a, nodes)

DESCRIPTION ^

 GETNODES converts a history object to a nodes structure suitable for plotting as a tree.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: GETNODES converts a history object to a nodes structure suitable
              for plotting as a tree.

 CALL:        [n,a, nodes] = getNodes(hist, [], 0, 1, []);

 VERSION:     $Id: getNodes.m,v 1.9 2007/07/18 13:58:44 ingo Exp $

 HISTORY:     02-02-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [n,a,nodes] = getNodes(h, n, pn, a, nodes)
0002 % GETNODES converts a history object to a nodes structure suitable for plotting as a tree.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: GETNODES converts a history object to a nodes structure suitable
0007 %              for plotting as a tree.
0008 %
0009 % CALL:        [n,a, nodes] = getNodes(hist, [], 0, 1, []);
0010 %
0011 % VERSION:     $Id: getNodes.m,v 1.9 2007/07/18 13:58:44 ingo Exp $
0012 %
0013 % HISTORY:     02-02-2007 M Hewitson
0014 %                 Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 % set my node to next number
0019 nn = get(h,'n');
0020 if nn<0
0021   h = set(h, 'n', a);
0022 end
0023 
0024 % set my parent node
0025 nn = get(h,'pn');
0026 if nn<0
0027   h = set(h, 'pn', pn);
0028   n = [n pn];
0029   nodes(a).pn     = pn;
0030   nodes(a).invars = get(h, 'invars');
0031   nodes(a).n      = get(h, 'n');
0032   nodes(a).names  = get(h, 'name');
0033   nodes(a).params = char(get(h, 'plist'));
0034   nodes(a).pl     = get(h, 'plist');
0035   nodes(a).h      = h;
0036 end
0037 % disp(['node: ' num2str(get(h, 'pn'))]);
0038 
0039 % I need my parent node
0040 pn = get(h, 'n');
0041 
0042 % get my children nodes
0043 ihs = get(h, 'inhists');
0044 
0045 % Now decide what to do with my children
0046 if isa(ihs, 'history')
0047   for i=1:length(ihs)
0048     % get child number
0049     nn = get(ihs(i), 'n');
0050     % if this child is not set
0051     if nn < 0
0052       % set it
0053       a = a + 1;
0054       [n,a, nodes] = getNodes(ihs(i), n, pn, a, nodes);
0055     else % else go back to my parent
0056       [n,a, nodes] = getNodes(h, n, get(h,'pn'), a, nodes);
0057     end
0058   end
0059 end
0060

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003