Home > classes > @param > display.m

display

PURPOSE ^

DISPLAY display a parameter

SYNOPSIS ^

function txt = display(p)

DESCRIPTION ^

 DISPLAY display a parameter

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

 DESCRIPTION: DISPLAY display a parameter

 VERSION: $Id: display.m,v 1.13 2007/08/13 11:55:17 ingo Exp $

 HISTORY: 30-01-2007 M Hewitson
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function txt = display(p)
0002 % DISPLAY display a parameter
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: DISPLAY display a parameter
0007 %
0008 % VERSION: $Id: display.m,v 1.13 2007/08/13 11:55:17 ingo Exp $
0009 %
0010 % HISTORY: 30-01-2007 M Hewitson
0011 %             Creation
0012 %
0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0014 
0015 txt = {};
0016 
0017 for i=1:length(p)
0018   banner = sprintf('---- param %d ----', i);
0019   txt{end+1} = banner;
0020 
0021   % get key and value
0022   name = get(p(i), 'key');
0023   v    = get(p(i), 'val');
0024 
0025   % convert value for printing
0026   if ischar(v)
0027     sval = v;
0028   elseif isnumeric(v)
0029     sval = '';
0030     for j=1:min(length(v), 10)
0031       sval = [sval sprintf('%g ', v(j))];
0032     end
0033     if length(v) > 10
0034       sval = [sval '...'];
0035     end
0036   elseif isa(v, 'specwin');
0037     sval = char(v);
0038   elseif isa(v, 'miir');
0039     sval = char(v);
0040   elseif isa(v, 'time') || isa(v, 'timespan') || isa(v, 'timeformat')
0041     sval = char(v);
0042   elseif isa(v, 'mfir');
0043     sval = char(v);
0044   %!!!!!!!!!!!!!
0045   % Here I'm assuming there is a name field in the structure
0046   % - what else could we display here??
0047   %
0048   elseif isstruct(v)
0049     sval = v.name;
0050   elseif isa(v, 'ao') || isa(v, 'fsdata') || isa(v, 'tsdata') || isa(v, 'cdata')
0051     vinfo = whos('v');
0052     sval = vinfo.class;
0053   elseif isa(v, 'pole') || isa(v, 'zero') || isa(v, 'pzmodel')
0054     sval = '';
0055     for j=1:length(v)
0056       sval = [sval ' ' char(v(j))];
0057     end
0058   elseif iscell(v)
0059     sval = '';
0060     for ii = 1:length(v)
0061       sval = [sval '''' v{ii} ''' '];
0062     end
0063   else
0064     error('### parameter has unknown type')
0065   end
0066 
0067   % display
0068   txt{end+1} = sprintf('key: %s\nval: %s', name, deblank(sval));
0069 
0070   banner_end(1:length(banner)) = '-';
0071   txt{end+1} = banner_end;
0072 
0073 end
0074 
0075 if nargout == 0
0076   for ii=1:length(txt)
0077     disp(txt{ii});
0078   end
0079 end
0080 
0081 
0082

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