Home > classes > @param > display.m

display

PURPOSE ^

DISPLAY display a parameter

SYNOPSIS ^

function txt = display(p, varargin)

DESCRIPTION ^

 DISPLAY display a parameter

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

 DESCRIPTION: DISPLAY display a parameter

 VERSION: $Id: display.m,v 1.20 2007/12/11 17:27:09 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, varargin)
0002 % DISPLAY display a parameter
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: DISPLAY display a parameter
0007 %
0008 % VERSION: $Id: display.m,v 1.20 2007/12/11 17:27:09 ingo Exp $
0009 %
0010 % HISTORY: 30-01-2007 M Hewitson
0011 %             Creation
0012 %
0013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0014 
0015 VERSION = '$Id: display.m,v 1.20 2007/12/11 17:27:09 ingo Exp $';
0016 
0017 % Check if this is a call for parameters
0018 if nargin == 2
0019   if isa(p, 'param') && ischar(varargin{1})
0020     in = char(varargin{1});
0021     if strcmp(in, 'Params')
0022       txt = plist();
0023       return
0024     elseif strcmp(in, 'Version')
0025       txt = VERSION;
0026       return
0027     end
0028   end
0029 end
0030 
0031 txt = {};
0032 
0033 for i=1:numel(p)
0034   banner = sprintf('---- param %d ----', i);
0035   txt{end+1} = banner;
0036 
0037   % get key and value
0038   name = get(p(i), 'key');
0039   v    = get(p(i), 'val');
0040 
0041   txt{end+1} = ['key: ' name];
0042 
0043   % convert value for printing
0044 
0045 
0046   %%%%%   Character   %%%%%
0047   if ischar(v)
0048     if length(v) > 45
0049       txt{end+1} = ['val: ''' v(1:45) ' ...'''];
0050     else
0051       txt{end+1} = ['val: ''' v ''''];
0052     end
0053 
0054   %%%%%   Logical   %%%%%
0055   elseif islogical(v)
0056     if v == true
0057       txt{end+1} = 'val: true';
0058     else
0059       txt{end+1} = 'val: false';
0060     end
0061 
0062   %%%%%   Numeric   %%%%%
0063   elseif isnumeric(v)
0064     sval = '';
0065     if size(v,1) == 1 || size(v,2) == 1
0066       for j=1:min(length(v), 10)
0067         sval = [sval sprintf('%g ', v(j))];
0068       end
0069       if length(v) > 10
0070         sval = [sval '...'];
0071       end
0072     elseif isempty(v)
0073       sval = '[]';
0074     else
0075       sval = sprintf('Matrix [%dx%d]', size(v,1), size(v,2));
0076     end
0077     txt{end+1} = ['val: ' sval];
0078 
0079   %%%%%   Specwin Object   %%%%%
0080   elseif isa(v, 'specwin');
0081     txt{end+1} = ['val: ' v.name];
0082     txt{end+1} = ['     alpha    = ' num2str(v.alpha)];
0083     txt{end+1} = ['     psll     = ' num2str(v.psll)];
0084     txt{end+1} = ['     rov      = ' num2str(v.rov)];
0085     txt{end+1} = ['     nenbw    = ' num2str(v.nenbw)];
0086     txt{end+1} = ['     w3db     = ' num2str(v.w3db)];
0087     txt{end+1} = ['     flatness = ' num2str(v.flatness)];
0088 
0089   %%%%%   Provenance Object   %%%%%
0090   elseif isa(v, 'provenance')
0091     txt{end+1} = ['val: ' v.creator '@' v.hostname ' (' v.ip ')'];
0092 
0093   %%%%%   miir and mfir Object   %%%%%
0094   elseif isa(v, 'miir') || isa(v, 'mfir')
0095     txt{end+1} = ['val: ' char(v)];
0096 
0097   %%%%%   time, timespan and timeformat Object   %%%%%
0098   elseif isa(v, 'time') || isa(v, 'timespan') || isa(v, 'timeformat')
0099     txt{end+1} = ['val: ' char(v)];
0100 
0101   %%%%%   ao                              %%%%%
0102   %%%%%   cdata, fsdata, tsdata, xydata   %%%%%
0103   %%%%%   plist, param                    %%%%%
0104   %%%%%   history                         %%%%%
0105   elseif isa(v, 'ao')    || isa(v, 'fsdata')  || isa(v, 'tsdata') || ...
0106          isa(v, 'cdata') || isa(v, 'xydata')  || isa(v, 'plist')  || ...
0107          isa(v, 'param') || isa(v, 'history')
0108     vinfo = whos('v');
0109     txt{end+1} = ['val: ' vinfo.class '-object'];
0110 
0111   %%%%%   pole, zero and pole/zero model Object   %%%%%
0112   elseif isa(v, 'pole') || isa(v, 'zero') || isa(v, 'pzmodel')
0113     sval = '';
0114     for j=1:length(v)
0115       sval = [sval ' ' char(v(j))];
0116     end
0117     txt{end+1} = ['val: ' sval];
0118 
0119   %%%%%   Structures   %%%%%
0120   elseif isstruct(v)
0121 
0122     fields = fieldnames(v);
0123     txt{end+1} = 'val: structure';
0124     for ii=1:length(fields)
0125       field = fields{ii};
0126       if ischar(v.(field))
0127         txt{end+1} = ['     ' field ': ''' v.(field) ''''];
0128       elseif isnumeric(v.(field))
0129         txt{end+1} = ['     ' field ': ' ltpda_mat2str(v.(field))];
0130       elseif isobject(v.(field))
0131         txt{end+1} = ['     ' field ': ' class(v.(field)) '-object'];
0132       else
0133         error('### Do not use a [%s] in a cell array', class(v));
0134       end
0135     end
0136 
0137   %%%%%   Cell   %%%%%
0138   elseif iscell(v)
0139     sval = '';
0140     for ii = 1:length(v)
0141       if ischar(v{ii})
0142         sval = [sval '''' v{ii} ''' '];
0143       elseif isnumeric(v{ii})
0144         sval = [sval '[' ltpda_mat2str(v{ii}) '] '];
0145       elseif isobject(v{ii})
0146         sval = [sval '''' class(v{ii}) ''' '];
0147       else
0148         error('### Do not use a [%s] in a cell array', class(v));
0149       end
0150     end
0151     txt{end+1} = ['val: ' sval];
0152 
0153   %%%%%   JAVA   %%%%%
0154   elseif isjava(v)
0155     txt{end+1} = ['val: ' class(v)];
0156 
0157   else
0158     error('### parameter has unknown type')
0159   end
0160 
0161   banner_end(1:length(banner)) = '-';
0162   txt{end+1} = banner_end;
0163 
0164 end
0165 
0166 if nargout == 0
0167   for ii=1:length(txt)
0168     disp(txt{ii});
0169   end
0170 end
0171 
0172 
0173

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003