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