0001 function ao_out = complex(a1, a2)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 ALGONAME = mfilename;
0025 VERSION = '$Id: complex.m,v 1.5 2007/11/02 13:17:41 ingo Exp $';
0026
0027
0028 if nargin == 2
0029 if isa(a1, 'ao') && ischar(a2)
0030 in = char(a2);
0031 if strcmp(in, 'Params')
0032 ao_out = plist();
0033 return
0034 elseif strcmp(in, 'Version')
0035 ao_out = VERSION;
0036 return
0037 end
0038 end
0039 end
0040
0041
0042 if ~strcmp(class(a1.data), class(a2.data))
0043 error ('### The data class must be the same. (%s <-> %s)', ...
0044 class(a1.data), class(a2.data));
0045 end
0046
0047
0048 fields = fieldnames(a1.data);
0049 if ismember('fs', fields)
0050 if a1.data.fs ~= a2.data.fs
0051 error('### The sample rate is not the same. Please resaple one of the AO''s');
0052 end
0053 end
0054
0055
0056 [x1,y1] = get_xy_values(a1.data);
0057 [x2,y2] = get_xy_values(a2.data);
0058 if length(x1) ~= length(x2) || length(y1) ~= length(y2)
0059 error ('### The length of the data vectors must be the same.')
0060 end
0061
0062 complex_x = x1;
0063 complex_y = complex(y1, y2);
0064
0065 cmd = sprintf('data = %s(complex_x, complex_y);', class(a1.data));
0066 eval(cmd);
0067
0068 data = set(data, 'name', 'complex');
0069 data = set(data, 'xunits', a1.data.xunits);
0070 data = set(data, 'yunits', a1.data.yunits);
0071
0072 h = history(ALGONAME, VERSION, plist(), [a1.hist a2.hist]);
0073 h = set(h, 'invars', {inputname(1), inputname(2)});
0074
0075 ao_out = ao(data, h);
0076 ao_out = set(ao_out, 'name', sprintf('complex(%s, %s)', inputname(1), inputname(2)));
0077
0078
0079
0080
0081
0082
0083
0084
0085