0001 function txt = display(hists, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 VERSION = '$Id: display.m,v 1.9 2008/01/08 16:39:11 ingo Exp $';
0022
0023
0024 if nargin == 2
0025 if isa(hists, 'history') && ischar(varargin{1})
0026 in = char(varargin{1});
0027 if strcmp(in, 'Params')
0028 txt = plist();
0029 return
0030 elseif strcmp(in, 'Version')
0031 txt = VERSION;
0032 return
0033 end
0034 end
0035 end
0036
0037 txt = {};
0038
0039 for i=1:numel(hists)
0040 h = hists(i);
0041 banner = sprintf('-------- %s / %s / %d ------------', get(h, 'name'), ...
0042 get(h, 'version'), ...
0043 get(h, 'n'));
0044 txt{end+1} = banner;
0045
0046 txt{end+1} = ' ';
0047 txt{end+1} = sprintf('created: %s', char(h.created));
0048
0049
0050 txt{end+1} = ['Inputs: ' get(h, 'invars')];
0051
0052
0053 txt{end+1} = 'Parameters';
0054 txt{end+1} = '----------';
0055 pl = get(h, 'plist');
0056 if ~isempty(pl)
0057 txt{end+1} = display(pl);
0058 end
0059
0060 txt{end+1} = ' ';
0061
0062 txt{end+1} = 'Histories';
0063 txt{end+1} = '---------';
0064
0065
0066 inhists = get(h, 'inhists');
0067 nhists = length(inhists);
0068 txt{end+1} = sprintf('n input histories: %d', nhists);
0069 if nhists > 0
0070 txt{end+1} = display(inhists);
0071 end
0072
0073 txt{end+1} = ' ';
0074
0075 bannerEnd = [];
0076 while length(bannerEnd) < length(banner)
0077 bannerEnd = [bannerEnd '-'];
0078 end
0079 txt{end+1} = bannerEnd;
0080
0081 txt{end+1} = ' ';
0082 txt{end+1} = ' ';
0083 end
0084
0085 txt = single_cell(txt);
0086
0087 if nargout == 0
0088 for ii=1:length(txt)
0089 disp(txt{ii});
0090 end
0091 end
0092
0093
0094
0095 function new_txt = single_cell(txt_field)
0096
0097 new_txt = {};
0098 for ii=1:length(txt_field)
0099 if iscell(txt_field{ii})
0100 hh = single_cell(txt_field{ii});
0101 new_txt(end+1:end+length(hh)) = hh(1:end);
0102 else
0103 new_txt{end+1} = txt_field{ii};
0104 end
0105 end
0106
0107