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 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 % HISTORY: 12-03-07 M Hewitson 0021 % Creation 0022 % 0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0024 0025 ALGONAME = mfilename; 0026 VERSION = '$Id: abs.html,v 1.1 2007/06/08 14:15:02 hewitson Exp $'; 0027 0028 ao_set = []; 0029 ao_out = []; 0030 pl = []; 0031 0032 %% store the input ao's in the vector: ao_set 0033 for i=1:nargin 0034 a = varargin{i}; 0035 if isa(a, 'ao') 0036 [m,n] = size(a); 0037 for i = 1:m 0038 for j = 1:n 0039 ao_set = [ao_set a(i,j)]; 0040 end 0041 end 0042 elseif isa(varargin{i}, 'plist') 0043 pl = [pl varargin{i}]; 0044 end 0045 end 0046 0047 0048 %% capture input variable names 0049 invars = {}; 0050 for j=1:nargin 0051 invars = [invars cellstr(inputname(j))]; 0052 end 0053 0054 0055 %% go through analysis objects 0056 for j=1:length(ao_set) 0057 a = ao_set(j); 0058 0059 [h, abs_data] = single_operation(a.data, 'abs', pl); 0060 0061 %% Set the x, y-units to their old values (without abs()) 0062 abs_data = set(abs_data, 'xunits', a.data.xunits); 0063 abs_data = set(abs_data, 'yunits', a.data.yunits); 0064 %% It is nicer with the absolute signs | | than abs () 0065 abs_data = set(abs_data, 'name', sprintf ('| %s |',a.data.name)); 0066 0067 %% Add the history from the ao object to the history 0068 h = set(h, 'inhists', [a.hist]); 0069 0070 %% Set the var_name to the history 0071 if (j <= nargin) 0072 if (isempty (inputname(j))) 0073 h = set(h, 'invars', cellstr('no var_name')); 0074 else 0075 h = set(h, 'invars', cellstr(inputname(j))); 0076 end 0077 else 0078 h = set(h, 'invars', cellstr('no var_name')); 0079 end 0080 0081 %% create a new analysis objects 0082 new_ao = a; 0083 new_ao = ao (abs_data, h); 0084 new_ao = set (new_ao, 'name', sprintf('|%s|',a.name) ); 0085 0086 ao_out = [ao_out new_ao]; 0087 0088 end 0089 0090 % END