


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, []);
OUTPUT: n: A vector of parent pointers
a: Number of nodes
nodes: Struct of the nodes
VERSION: $Id: getNodes.m,v 1.10 2007/12/04 18:16:11 ingo Exp $
HISTORY: 02-02-2007 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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 % OUTPUT: n: A vector of parent pointers 0012 % a: Number of nodes 0013 % nodes: Struct of the nodes 0014 % 0015 % VERSION: $Id: getNodes.m,v 1.10 2007/12/04 18:16:11 ingo Exp $ 0016 % 0017 % HISTORY: 02-02-2007 M Hewitson 0018 % Creation 0019 % 0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 0022 VERSION = '$Id: getNodes.m,v 1.10 2007/12/04 18:16:11 ingo Exp $'; 0023 0024 % Check if this is a call for parameters 0025 if nargin == 2 0026 if isa(h, 'history') && ischar(n) 0027 in = char(n); 0028 if strcmp(in, 'Params') 0029 n = plist; 0030 return 0031 elseif strcmp(in, 'Version') 0032 n = VERSION; 0033 return 0034 end 0035 end 0036 end 0037 0038 0039 % set my node to next number 0040 nn = get(h,'n'); 0041 if nn<0 0042 h = set(h, 'n', a); 0043 end 0044 0045 % set my parent node 0046 nn = get(h,'pn'); 0047 if nn<0 0048 h = set(h, 'pn', pn); 0049 n = [n pn]; 0050 nodes(a).pn = pn; 0051 nodes(a).invars = get(h, 'invars'); 0052 nodes(a).n = get(h, 'n'); 0053 nodes(a).names = get(h, 'name'); 0054 nodes(a).params = char(get(h, 'plist')); 0055 nodes(a).pl = get(h, 'plist'); 0056 nodes(a).h = h; 0057 end 0058 % disp(['node: ' num2str(get(h, 'pn'))]); 0059 0060 % I need my parent node 0061 pn = get(h, 'n'); 0062 0063 % get my children nodes 0064 ihs = get(h, 'inhists'); 0065 0066 % Now decide what to do with my children 0067 if isa(ihs, 'history') 0068 for i=1:length(ihs) 0069 % get child number 0070 nn = get(ihs(i), 'n'); 0071 % if this child is not set 0072 if nn < 0 0073 % set it 0074 a = a + 1; 0075 [n,a, nodes] = getNodes(ihs(i), n, pn, a, nodes); 0076 else % else go back to my parent 0077 [n,a, nodes] = getNodes(h, n, get(h,'pn'), a, nodes); 0078 end 0079 end 0080 end 0081