Home > classes > @ao > complex.m

complex

PURPOSE ^

COMPLEX overloads the complex operator for Analysis objects.

SYNOPSIS ^

function ao_out = complex(a1, a2)

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 A + Bi, where A and B
              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 = imag(ao, 'Params')

 VERSION:     $Id: complex.m,v 1.2 2007/08/21 11:30:43 ingo 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(a1, a2)
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 A + Bi, where A and B
0008 %              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 = imag(ao, 'Params')
0016 %
0017 % VERSION:     $Id: complex.m,v 1.2 2007/08/21 11:30:43 ingo Exp $
0018 %
0019 % HISTORY:     20-08-2007 Diepholz
0020 %                 Creation
0021 %
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 
0024 ALGONAME = mfilename;
0025 VERSION  = '$Id: complex.m,v 1.2 2007/08/21 11:30:43 ingo Exp $';
0026 
0027 % Check if this is a call for parameters
0028 if nargin == 2
0029   if isa(a1, 'ao') && ischar(a2)
0030     in = char(a2);
0031     if strcmp(in, 'Params')
0032       ao_out = getDefaultPL();
0033       return
0034     end
0035   end
0036 end
0037 
0038 % Check for the same data.
0039 if ~strcmp(class(a1.data), class(a2.data))
0040   error ('### The data class must be the same. (%s <-> %s)', ...
0041           class(a1.data), class(a2.data));
0042 end
0043 
0044 % Check for the same sampe rate
0045 fields = fieldnames(a1.data);
0046 if ismember('fs', fields)
0047   if a1.data.fs ~= a2.data.fs
0048     error('### The sample rate is not the same. Please resaple one of the AO''s');
0049   end
0050 end
0051 
0052 % Check the length of the AO's
0053 [x1,y1] = get_xy_axis(a1.data);
0054 [x2,y2] = get_xy_axis(a2.data);
0055 if length(x1) ~= length(x2) || length(y1) ~= length(y2)
0056   error ('### The length of the data vectors must be the same.')
0057 end
0058 
0059 complex_x = x1;
0060 complex_y = complex(y1, y2);
0061 
0062 cmd = sprintf('data = %s(complex_x, complex_y)', class(a1.data));
0063 eval(cmd);
0064 
0065 data = set(data, 'name',  'complex');
0066 data = set(data, 'xunits', a1.data.xunits);
0067 data = set(data, 'yunits', a1.data.yunits);
0068 
0069 h = history(ALGONAME, VERSION, [], [a1.hist a2.hist]);
0070 h = set(h, 'invars', {inputname(1), inputname(2)});
0071 
0072 ao_out = ao(data, h);
0073 ao_out = set(ao_out, 'name', sprintf('complex(%s, %s)', inputname(1), inputname(2)));
0074 
0075 
0076 
0077 
0078 
0079 
0080 
0081 
0082

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003