Home > classes > @ao > cos.m

cos

PURPOSE ^

COS overloads the cos operator for Analysis objects. Cosine of argument in radians.

SYNOPSIS ^

function ao_out = cos (varargin)

DESCRIPTION ^

 COS overloads the cos operator for Analysis objects. Cosine of argument in radians.

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

 DESCRIPTION: COS overloads the cos operator for Analysis objects.
              Cosine of argument in radians.
              COS(ao) is the cosine of the elements of ao.data.

 CALL: ao_out = cos(ao_in);
       ao_out = cos(ao_in, pl);
       ao_out = cos(ao1, pl1, ao_vector, ao_matrix, pl2);

 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 = cos(ao, 'Params')

 HISTORY: 07-05-2007 Diepholz
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function ao_out = cos (varargin)
0002 % COS overloads the cos operator for Analysis objects. Cosine of argument in radians.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: COS overloads the cos operator for Analysis objects.
0007 %              Cosine of argument in radians.
0008 %              COS(ao) is the cosine of the elements of ao.data.
0009 %
0010 % CALL: ao_out = cos(ao_in);
0011 %       ao_out = cos(ao_in, pl);
0012 %       ao_out = cos(ao1, pl1, ao_vector, ao_matrix, pl2);
0013 %
0014 % POSSIBLE VALUES: ao_in  = [ao2 ao3]
0015 %                  ao_in  = ao_vector
0016 %                  ao_in  = ao_matrix
0017 %
0018 % PARAMETER LIST:  <key>           <value>             <description>
0019 %                          tsdata  fsdata  xydata
0020 %                 'xdata'   't'     'f'      'x'     compute the xdata
0021 %                 'ydata'   'x'     'xx'     'y'     compute the ydata
0022 %
0023 % The following call returns a parameter list object that contains the
0024 % default parameter values:
0025 %
0026 % >> pl = cos(ao, 'Params')
0027 %
0028 % HISTORY: 07-05-2007 Diepholz
0029 %             Creation
0030 %
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 
0033 VERSION = '$Id: cos.m,v 1.8 2007/11/26 14:48:13 ingo Exp $';
0034 ao_out  = [];
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 %% 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 [ao_set, pl, invars] = collect_inputs(varargin, in_names);
0057 
0058 if ~isempty (pl)
0059   pl = combine(pl);
0060 end
0061 
0062 %% go through analysis objects
0063 for j=1:numel(ao_set)
0064   a = ao_set(j);
0065 
0066   [h, cos_data] = single_operation(a.data, 'cos', pl);
0067 
0068   %% Add the history from the ao object to the history
0069   h = set(h, 'inhists', [a.hist]);
0070 
0071   %% Set the var_name to the history
0072   h = set(h, 'invars', cellstr(invars{j}));
0073 
0074   %% create a new analysis objects
0075   new_ao = a;
0076   new_ao = ao  (cos_data, h);
0077   new_ao = setnh (new_ao, 'name', sprintf('cos(%s)',invars{j}) );
0078 
0079   ao_out = [ao_out new_ao];
0080 
0081 end
0082 
0083 % Reshape the ouput to the same size of the input
0084 ao_out = reshape(ao_out, size(ao_set));
0085 
0086 %% Get default params
0087 function pl_default = getDefaultPL()
0088 
0089   pl_default = plist([param('xdata',  '')
0090                       param('ydata',  '')]);
0091 
0092 % END

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003