


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.15 2008/01/20 12:53:29 hewitson 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.15 2008/01/20 12:53:29 hewitson 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.15 2008/01/20 12:53:29 hewitson Exp $'; 0035 bs = []; 0036 0037 if nargin == 2 0038 if isa(varargin{1}, 'ao') && ischar(varargin{2}) 0039 in = char(varargin{2}); 0040 if strcmp(in, 'Params') 0041 varargout{1} = getDefaultPL(); 0042 return 0043 elseif strcmp(in, 'Version') 0044 varargout{1} = VERSION; 0045 return 0046 end 0047 end 0048 end 0049 0050 %% Collect input ao's, plist's and ao variable names 0051 in_names = {}; 0052 for ii = 1:nargin 0053 in_names{end+1} = inputname(ii); 0054 end 0055 0056 [as, pl, invars] = collect_inputs(varargin, in_names); 0057 0058 if ~isempty (pl) 0059 pl = combine(pl); 0060 end 0061 0062 0063 %% go through analysis objects 0064 for j=1:numel(as) 0065 a = as(j); 0066 0067 d = get(a, 'data'); 0068 dinfo = whos('d'); 0069 % Which data type do we have 0070 dtype = dinfo.class; 0071 switch dtype 0072 case 'cdata' 0073 %disp('* NORM of cdata object'); 0074 % make a new cdata object 0075 [h, c] = single_operation(d, 'norm',pl); 0076 0077 % make output analysis object 0078 h = set(h, 'inhists', [a.hist]); 0079 0080 %% Set the var_name to the history 0081 h = set(h, 'invars', cellstr(invars{j})); 0082 0083 b = ao(c, h); 0084 b = setnh(b, 'name', sprintf('norm(%s)', char(invars{j}))); 0085 case {'tsdata', 'fsdata', 'xydata'} 0086 error('### this function works for cdata type AO only') 0087 otherwise 0088 error('### unknown data type.') 0089 0090 end 0091 0092 % add to output 0093 bs = [bs b]; 0094 end 0095 0096 % Reshape the ouput to the same size of the input 0097 bs = reshape(bs, size(as)); 0098 varargout{1} = bs; 0099 0100 %% Get default params 0101 function plo = getDefaultPL() 0102 0103 plo = plist(); 0104 plo = append(plo, 'option', []); 0105 0106 0107 % END