Home > classes > @ao > complex.m

complex

PURPOSE ^

COMPLEX overloads the complex operator for Analysis objects.

SYNOPSIS ^

function ao_out = complex(varargin)

DESCRIPTION ^

 COMPLEX overloads the complex operator for Analysis objects.

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

 DESCRIPTION: COMPLEX overloads the complex operator for Analysis objects.
              A3 = COMPLEX(A1,A2) returns the complex result A1 + A2i,
              where A1 and A2 are identically sized real arrays.

 CALL:        ao_out = complex(a1, a2);

 The following call returns a parameter list object that contains the
 default parameter values:

 >> pl = complex(ao, 'Params')

 The following call returns a string that contains the routine CVS version:

 >> version = complex(ao,'Version')

 The following call returns a string that contains the routine category:

 >> category = complex(ao,'Category')

 VERSION:     $Id: complex.m,v 1.10 2008/03/26 15:11:59 mauro Exp $

 HISTORY:     20-08-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ao_out = complex(varargin)
0002 % COMPLEX overloads the complex operator for Analysis objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: COMPLEX overloads the complex operator for Analysis objects.
0007 %              A3 = COMPLEX(A1,A2) returns the complex result A1 + A2i,
0008 %              where A1 and A2 are identically sized real arrays.
0009 %
0010 % CALL:        ao_out = complex(a1, a2);
0011 %
0012 % The following call returns a parameter list object that contains the
0013 % default parameter values:
0014 %
0015 % >> pl = complex(ao, 'Params')
0016 %
0017 % The following call returns a string that contains the routine CVS version:
0018 %
0019 % >> version = complex(ao,'Version')
0020 %
0021 % The following call returns a string that contains the routine category:
0022 %
0023 % >> category = complex(ao,'Category')
0024 %
0025 % VERSION:     $Id: complex.m,v 1.10 2008/03/26 15:11:59 mauro Exp $
0026 %
0027 % HISTORY:     20-08-2007 Diepholz
0028 %                 Creation
0029 %
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 ALGONAME = mfilename;
0033 VERSION  = '$Id: complex.m,v 1.10 2008/03/26 15:11:59 mauro Exp $';
0034 CATEGORY = 'Operator';
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 = plist();
0042       return
0043     elseif strcmp(in, 'Version')
0044       ao_out = VERSION;
0045       return
0046     elseif strcmp(in, 'Category')
0047       ao_out = CATEGORY;
0048       return
0049     end
0050   end
0051 end
0052 
0053 % Collect input ao's, plist's and ao variable names
0054 in_names = {};
0055 for ii = 1:nargin
0056   in_names{end+1} = inputname(ii);
0057 end
0058 
0059 [as, pl, invars] = collect_inputs(varargin, in_names);
0060 
0061 % Check input arguments number
0062 if length(as) < 2
0063   error ('### Incorrect call! Please enter 2 AOs');
0064 end
0065 
0066 % Selects inputs
0067 a1 = as(1);
0068 a2 = as(2);
0069 
0070 % Check for the same data.
0071 if ~strcmp(class(a1.data), class(a2.data))
0072   error ('### The data class must be the same. (%s <-> %s)', ...
0073           class(a1.data), class(a2.data));
0074 end
0075 
0076 % Check for the same sampe rate
0077 fields = fieldnames(a1.data);
0078 if ismember('fs', fields)
0079   if a1.data.fs ~= a2.data.fs
0080     error('### The sample rate is not the same. Please resaple one of the AO''s');
0081   end
0082 end
0083 
0084 % Check the length of the AO's
0085 [x1,y1] = get_xy_values(a1.data);
0086 [x2,y2] = get_xy_values(a2.data);
0087 if length(x1) ~= length(x2) || length(y1) ~= length(y2)
0088   error ('### The length of the data vectors must be the same.')
0089 end
0090 
0091 complex_x = x1;
0092 complex_y = complex(y1, y2);
0093 
0094 cmd = sprintf('data = %s(complex_x, complex_y);', class(a1.data));
0095 eval(cmd);
0096 
0097 data = set(data, 'name',  'complex');
0098 data = set(data, 'xunits', a1.data.xunits);
0099 data = set(data, 'yunits', a1.data.yunits);
0100 
0101 h = history(ALGONAME, VERSION, plist(), [a1.hist a2.hist]);
0102 h = set(h, 'invars', {inputname(1), inputname(2)});
0103 
0104 ao_out = ao(data, h);
0105 ao_out = setnh(ao_out, 'name', sprintf('complex(%s, %s)', inputname(1), inputname(2)));
0106 
0107 
0108 
0109 
0110 
0111 
0112 
0113 
0114

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003