


ABS overloads the Absolute value operator for Analysis objects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: ABS overloads the Absolute value operator for Analysis objects.
CALL: ao_out = abs(ao_in);
ao_out = abs(ao_in, pl);
POSSIBLE VALUES: ao_in = [ao2 ao3]
ao_in = ao_vector
ao_in = ao_matrix
PARAMETER LIST: <key> <value> <description>
tsdata fsdata xydata
'xdata' 't' 'f' 'x' compute the xdata
'ydata' 'x' 'xx' 'y' compute the ydata
The following call returns a parameter list object that contains the
default parameter values:
>> pl = abs(ao, 'Params')
HISTORY: 12-03-07 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 function ao_out = abs(varargin) 0002 % ABS overloads the Absolute value operator for Analysis objects. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: ABS overloads the Absolute value operator for Analysis objects. 0007 % 0008 % CALL: ao_out = abs(ao_in); 0009 % ao_out = abs(ao_in, pl); 0010 % 0011 % POSSIBLE VALUES: ao_in = [ao2 ao3] 0012 % ao_in = ao_vector 0013 % ao_in = ao_matrix 0014 % 0015 % PARAMETER LIST: <key> <value> <description> 0016 % tsdata fsdata xydata 0017 % 'xdata' 't' 'f' 'x' compute the xdata 0018 % 'ydata' 'x' 'xx' 'y' compute the ydata 0019 % 0020 % The following call returns a parameter list object that contains the 0021 % default parameter values: 0022 % 0023 % >> pl = abs(ao, 'Params') 0024 % 0025 % HISTORY: 12-03-07 M Hewitson 0026 % Creation 0027 % 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 0030 VERSION = '$Id: abs.m,v 1.11 2008/01/15 20:33:07 hewitson Exp $'; 0031 CATEGORY = 'operator'; 0032 0033 ao_out = []; 0034 0035 %% Check if this is a call for parameters 0036 if nargin == 2 0037 if isa(varargin{1}, 'ao') && ischar(varargin{2}) 0038 in = char(varargin{2}); 0039 if strcmp(in, 'Params') 0040 ao_out = getDefaultPL(); 0041 return 0042 elseif strcmp(in, 'Version') 0043 ao_out = VERSION; 0044 return 0045 elseif strcmp(in, 'Category') 0046 ao_out = CATEGORY; 0047 return 0048 end 0049 end 0050 end 0051 0052 %% Collect input ao's, plist's and ao variable names 0053 in_names = {}; 0054 for ii = 1:nargin 0055 in_names{end+1} = inputname(ii); 0056 end 0057 0058 [aos, pls, invars] = collect_inputs(varargin, in_names); 0059 0060 if ~isempty (pls) 0061 pls = combine(pls); 0062 end 0063 0064 %% go through analysis objects 0065 for j=1:numel(aos) 0066 a = aos(j); 0067 0068 [h, abs_data] = single_operation(a.data, 'abs', pls); 0069 0070 %% Set the x, y-units to their old values (without abs()) 0071 abs_data = set(abs_data, 'xunits', a.data.xunits); 0072 abs_data = set(abs_data, 'yunits', a.data.yunits); 0073 %% It is nicer with the absolute signs | | than abs () 0074 abs_data = set(abs_data, 'name', sprintf ('| %s |',a.data.name)); 0075 0076 %% Add the history from the ao object to the history 0077 h = set(h, 'inhists', [a.hist]); 0078 0079 %% Set the var_name to the history 0080 h = set(h, 'invars', cellstr(invars{j})); 0081 0082 %% create a new analysis objects 0083 new_ao = ao (abs_data, h); 0084 new_ao = setnh(new_ao, 'name', sprintf('|%s|',invars{j}) ); 0085 0086 ao_out = [ao_out new_ao]; 0087 0088 end 0089 0090 % Reshape the ouput to the same size of the input 0091 ao_out = reshape(ao_out, size(aos)); 0092 0093 0094 %% Get default params 0095 function pl_default = getDefaultPL() 0096 0097 pl_default = plist([param('xdata', '') 0098 param('ydata', '')]); 0099 0100 % END