NORM overloads the norm operator for Analysis Objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION:NORM overloads the norm operator for Analysis Objects. CALL: b = norm (a,pl) % only with data = cdata b = norm (a) INPUTS: pl - a parameter list a - input analysis object OUTPUTS: like matlab fct Parameters: 'option' - a string or value that can be submited i.e. 'inf' for the infinity norm of the input ao, the largest row sum options are the same as for the matlab function VERSION: $Id: norm.m,v 1.12 2007/09/27 09:03:25 ingo Exp $ The following call returns a parameter list object that contains the default parameter values: >> pl = norm(ao, 'Params') HISTORY: 08-05-07 A Monsky Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function varargout = norm(varargin) 0002 % NORM overloads the norm operator for Analysis Objects. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION:NORM overloads the norm operator for Analysis Objects. 0007 % 0008 % CALL: b = norm (a,pl) % only with data = cdata 0009 % b = norm (a) 0010 % 0011 % INPUTS: pl - a parameter list 0012 % a - input analysis object 0013 % 0014 % OUTPUTS: like matlab fct 0015 % 0016 % Parameters: 'option' - a string or value that can be submited i.e. 'inf' for 0017 % the infinity norm of the input ao, the largest row sum 0018 % options are the same as for the matlab function 0019 % 0020 % VERSION: $Id: norm.m,v 1.12 2007/09/27 09:03:25 ingo Exp $ 0021 % 0022 % The following call returns a parameter list object that contains the 0023 % default parameter values: 0024 % 0025 % >> pl = norm(ao, 'Params') 0026 % 0027 % HISTORY: 08-05-07 A Monsky 0028 % Creation 0029 % 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 0032 %% Check if this is a call for parameters 0033 0034 VERSION = '$Id: norm.m,v 1.12 2007/09/27 09:03:25 ingo Exp $'; 0035 0036 if nargin == 2 0037 if isa(varargin{1}, 'ao') && ischar(varargin{2}) 0038 in = char(varargin{2}); 0039 if strcmp(in, 'Params') 0040 varargout{1} = getDefaultPL(); 0041 return 0042 elseif strcmp(in, 'Version') 0043 varargout{1} = VERSION; 0044 return 0045 end 0046 end 0047 end 0048 0049 % capture input variable names 0050 invars = {}; 0051 0052 as = []; 0053 pl = []; 0054 bs = []; 0055 0056 for j=1:nargin 0057 invars = [invars cellstr(inputname(j))]; 0058 if isa(varargin{j}, 'ao') 0059 as = [as varargin{j}]; 0060 end 0061 if isa(varargin{j}, 'plist') 0062 pl = [pl varargin{j}]; 0063 end 0064 end 0065 0066 if ~isempty (pl) 0067 pl = combine(pl); 0068 end 0069 0070 0071 %% go through analysis objects 0072 for j=1:numel(as) 0073 a = as(j); 0074 0075 d = get(a, 'data'); 0076 dinfo = whos('d'); 0077 % Which data type do we have 0078 dtype = dinfo.class; 0079 switch dtype 0080 case 'cdata' 0081 disp('* NORM of cdata object'); 0082 % make a new cdata object 0083 [h, c] = single_operation(d, 'norm',pl); 0084 0085 % make output analysis object 0086 h = set(h, 'inhists', [a.hist]); 0087 0088 %% Set the var_name to the history 0089 if (j <= nargin) 0090 if (isempty (inputname(j))) 0091 h = set(h, 'invars', cellstr('no var_name')); 0092 else 0093 h = set(h, 'invars', cellstr(inputname(j))); 0094 end 0095 else 0096 h = set(h, 'invars', cellstr('no var_name')); 0097 end 0098 0099 b = ao(c, h); 0100 b = set(b, 'name', sprintf('norm(%s)', char(invars{1}))); 0101 case {'tsdata', 'fsdata', 'xydata'} 0102 error('### this function works for cdata type AO only') 0103 otherwise 0104 error('### unknown data type.') 0105 0106 end 0107 0108 % add to output 0109 bs = [bs b]; 0110 end 0111 0112 % Reshape the ouput to the same size of the input 0113 bs = reshape(bs, size(as)); 0114 varargout{1} = bs; 0115 0116 %% Get default params 0117 function plo = getDefaultPL() 0118 0119 plo = plist(); 0120 plo = append(plo, 'option', []); 0121 0122 0123 % END