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

Generated on Fri 07-Mar-2008 15:46:43 by m2html © 2003