GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree. CALL: [n,a, nodes] = getNodes(hist, [], 0, 1, [], 0, 2); OUTPUT: n: A vector of parent pointers a: Number of nodes nodes: Struct of the nodes REMARK: This version is equivalent to getNodes with the different that this function only return the nodes up to the MAX_DEPTH. VERSION: $Id: getNodes_plot.html,v 1.13 2008/03/31 10:27:38 hewitson Exp $ HISTORY: 14-06-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [varargout] = getNodes_plot(varargin) 0002 % GETNODES_PLOT converts a history object to a nodes structure suitable for plotting as a tree. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: GETNODES_PLOT converts a history object to a nodes structure 0007 % suitable for plotting as a tree. 0008 % 0009 % CALL: [n,a, nodes] = getNodes(hist, [], 0, 1, [], 0, 2); 0010 % 0011 % OUTPUT: n: A vector of parent pointers 0012 % a: Number of nodes 0013 % nodes: Struct of the nodes 0014 % 0015 % REMARK: This version is equivalent to getNodes with the different that 0016 % this function only return the nodes up to the MAX_DEPTH. 0017 % 0018 % VERSION: $Id: getNodes_plot.html,v 1.13 2008/03/31 10:27:38 hewitson Exp $ 0019 % 0020 % HISTORY: 14-06-07 M Hewitson 0021 % Creation 0022 % 0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0024 0025 VERSION = '$Id: getNodes_plot.html,v 1.13 2008/03/31 10:27:38 hewitson Exp $'; 0026 CATEGORY = 'Internal'; 0027 0028 0029 % Prepare outputs 0030 n = []; 0031 a = []; 0032 nodes = []; 0033 0034 % Check if this is a call for parameters 0035 if nargin == 2 0036 if isa(varargin{1}, 'history') && ischar(varargin{2}) 0037 in = char(varargin{2}); 0038 if strcmp(in, 'Params') 0039 varargout{1} = plist; 0040 return 0041 elseif strcmp(in, 'Version') 0042 varargout{1} = VERSION; 0043 return 0044 elseif strcmp(in, 'Category') 0045 varargout{1} = CATEGORY; 0046 return 0047 end 0048 end 0049 end 0050 0051 % Set input 0052 h = varargin{1}; 0053 n = varargin{2}; 0054 pn = varargin{3}; 0055 a = varargin{4}; 0056 nodes = varargin{5}; 0057 depth = varargin{6}; 0058 MAX_DEPTH = varargin{7}; 0059 0060 % set my node to next number 0061 nn = h.n; %get(h,'n'); 0062 if nn<0 0063 h.n = a; % = set(h, 'n', a); 0064 end 0065 0066 % set my parent node 0067 nn = h.pn; %get(h,'pn'); 0068 if nn<0 0069 h.pn = pn; % = set(h, 'pn', pn); 0070 n = [n pn]; 0071 nodes(a).pn = pn; 0072 nodes(a).invars = h.invars; %get(h, 'invars'); 0073 nodes(a).n = h.n; %get(h, 'n'); 0074 nodes(a).names = h.name; %get(h, 'name'); 0075 nodes(a).params = char(h.plist); 0076 nodes(a).pl = h.plist; 0077 0078 if depth == MAX_DEPTH 0079 nodes(a).names = '...'; 0080 nodes(a).params = ''; 0081 nodes(a).invars = {}; 0082 end 0083 0084 end 0085 0086 % I need my parent node 0087 pn = h.n; %get(h, 'n'); 0088 0089 % get my children nodes 0090 ihs = h.inhists; %get(h, 'inhists'); 0091 0092 % Now decide what to do with my children 0093 if isa(ihs, 'history') 0094 for i=1:length(ihs) 0095 % get child number 0096 nn = ihs(i).n; %get(ihs(i), 'n'); 0097 % if this child is not set 0098 if nn < 0 0099 if depth < MAX_DEPTH 0100 0101 % set it 0102 a = a + 1; 0103 [n,a, nodes] = getNodes_plot(ihs(i), n, pn, a, nodes, depth+1, MAX_DEPTH); 0104 0105 end 0106 else % else go back to my parent 0107 [n,a, nodes] = getNodes_plot(h, n, get(h,'pn'), a, nodes, depth, MAX_DEPTH); 0108 end 0109 end 0110 0111 end 0112 0113 % Set outputs 0114 varargout{1} = n; 0115 varargout{2} = a; 0116 varargout{3} = nodes; 0117