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.16 2008/02/12 09:29:24 mauro Exp $ The following call returns a parameter list object that contains the default parameter values: >> pl = norm(ao, 'Params') The following call returns a string that contains the routine CVS version: >> version = norm(ao,'Version') The following call returns a string that contains the routine category: >> category = norm(ao,'Category') 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.16 2008/02/12 09:29:24 mauro 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 % The following call returns a string that contains the routine CVS version: 0028 % 0029 % >> version = norm(ao,'Version') 0030 % 0031 % The following call returns a string that contains the routine category: 0032 % 0033 % >> category = norm(ao,'Category') 0034 % 0035 % HISTORY: 08-05-07 A Monsky 0036 % Creation 0037 % 0038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0039 0040 0041 VERSION = '$Id: norm.m,v 1.16 2008/02/12 09:29:24 mauro Exp $'; 0042 CATEGORY = 'Operator'; 0043 0044 bs = []; 0045 0046 %% Check if this is a call for parameters, version or category 0047 if nargin == 2 0048 if isa(varargin{1}, 'ao') && ischar(varargin{2}) 0049 in = char(varargin{2}); 0050 if strcmp(in, 'Params') 0051 varargout{1} = getDefaultPL(); 0052 return 0053 elseif strcmp(in, 'Version') 0054 varargout{1} = VERSION; 0055 return 0056 elseif strcmp(in, 'Category') 0057 varargout{1} = CATEGORY; 0058 return 0059 end 0060 end 0061 end 0062 0063 %% Collect input ao's, plist's and ao variable names 0064 in_names = {}; 0065 for ii = 1:nargin 0066 in_names{end+1} = inputname(ii); 0067 end 0068 0069 [as, pl, invars] = collect_inputs(varargin, in_names); 0070 0071 if ~isempty (pl) 0072 pl = combine(pl); 0073 end 0074 0075 0076 %% go through analysis objects 0077 for j=1:numel(as) 0078 a = as(j); 0079 0080 d = get(a, 'data'); 0081 dinfo = whos('d'); 0082 % Which data type do we have 0083 dtype = dinfo.class; 0084 switch dtype 0085 case 'cdata' 0086 %disp('* NORM of cdata object'); 0087 % make a new cdata object 0088 [h, c] = single_operation(d, 'norm',pl); 0089 0090 % make output analysis object 0091 h = set(h, 'inhists', [a.hist]); 0092 0093 %% Set the var_name to the history 0094 h = set(h, 'invars', cellstr(invars{j})); 0095 0096 b = ao(c, h); 0097 b = setnh(b, 'name', sprintf('norm(%s)', char(invars{j}))); 0098 case {'tsdata', 'fsdata', 'xydata'} 0099 error('### this function works for cdata type AO only') 0100 otherwise 0101 error('### unknown data type.') 0102 0103 end 0104 0105 % add to output 0106 bs = [bs b]; 0107 end 0108 0109 % Reshape the ouput to the same size of the input 0110 bs = reshape(bs, size(as)); 0111 varargout{1} = bs; 0112 0113 %% Get default params 0114 function plo = getDefaultPL() 0115 0116 plo = plist(); 0117 plo = append(plo, 'option', []); 0118 0119 0120 % END