Home > classes > @ao > abs.m

abs

PURPOSE ^

ABS overloads the Absolute value operator for Analysis objects.

SYNOPSIS ^

function ao_out = abs(varargin)

DESCRIPTION ^

 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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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.6 2007/10/09 14:05:25 ingo Exp $';
0031 
0032 ao_set = [];
0033 ao_out = [];
0034 pl     = [];
0035 
0036 %% Check if this is a call for parameters
0037 if nargin == 2
0038   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0039     in = char(varargin{2});
0040     if strcmp(in, 'Params')
0041       ao_out = getDefaultPL();
0042       return
0043     elseif strcmp(in, 'Version')
0044       ao_out = VERSION;
0045       return
0046     end
0047   end
0048 end
0049 
0050 %% store the input ao's in the vector: ao_set
0051 for i=1:nargin
0052   a = varargin{i};
0053   if isa(a, 'ao')
0054     ao_set  = [ao_set varargin{i}];
0055   elseif isa(varargin{i}, 'plist')
0056     pl = [pl varargin{i}];
0057   end
0058 end
0059 
0060 
0061 %% capture input variable names
0062 invars = {};
0063 for j=1:nargin
0064   invars = [invars cellstr(inputname(j))];
0065 end
0066 
0067 
0068 %% go through analysis objects
0069 for j=1:numel(ao_set)
0070   a = ao_set(j);
0071 
0072   [h, abs_data] = single_operation(a.data, 'abs', pl);
0073 
0074   %% Set the x, y-units to their old values (without abs())
0075   abs_data = set(abs_data, 'xunits', a.data.xunits);
0076   abs_data = set(abs_data, 'yunits', a.data.yunits);
0077   %% It is nicer with the absolute signs | | than abs ()
0078   abs_data = set(abs_data, 'name', sprintf ('| %s |',a.data.name));
0079 
0080   %% Add the history from the ao object to the history
0081   h = set(h, 'inhists', [a.hist]);
0082 
0083   %% Set the var_name to the history
0084   if (j <= nargin)
0085     if (isempty (inputname(j)))
0086       h = set(h, 'invars', cellstr('no var_name'));
0087     else
0088       h = set(h, 'invars', cellstr(inputname(j)));
0089     end
0090   else
0091     h = set(h, 'invars', cellstr('no var_name'));
0092   end
0093 
0094   %% create a new analysis objects
0095   new_ao = ao  (abs_data, h);
0096   new_ao = set (new_ao, 'name', sprintf('|%s|',a.name) );
0097 
0098   ao_out = [ao_out new_ao];
0099 
0100 end
0101 
0102 % Reshape the ouput to the same size of the input
0103 ao_out = reshape(ao_out, size(ao_set));
0104 
0105 
0106 %% Get default params
0107 function pl_default = getDefaultPL()
0108 
0109   pl_default = plist([param('xdata',  '')
0110                       param('ydata',  '')]);
0111 
0112 % END

Generated on Fri 02-Nov-2007 19:39:27 by m2html © 2003