0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 function varargout = complex(varargin)
0024
0025
0026 if utils.helper.isinfocall(varargin{:})
0027 varargout{1} = getInfo(varargin{3});
0028 return
0029 end
0030
0031 import utils.const.*
0032 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
0033
0034
0035 in_names = cell(size(varargin));
0036 for ii = 1:nargin,in_names{ii} = inputname(ii);end
0037
0038
0039 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
0040
0041
0042 bs = copy(as, nargout);
0043
0044
0045 if length(bs) ~= 2
0046 error ('### Incorrect inputs. Please enter 2 AOs');
0047 end
0048
0049
0050 if isa(bs(1).data, 'data3D') || isa(bs(2).data, 'data3D')
0051 error('### 3D data objects are currently not supported.');
0052 end
0053
0054
0055 if ~strcmp(class(bs(1).data), class(bs(2).data))
0056 error ('### The data class of the two AOs must be the same. (%s <-> %s)', ...
0057 class(bs(1).data), class(bs(2).data));
0058 end
0059
0060
0061 fields = fieldnames(bs(1).data);
0062 if ismember('fs', fields)
0063 if bs(1).data.fs ~= bs(2).data.fs
0064 error('### The sample rate of the two AOs is not the same. Please resample one of them.');
0065 end
0066 end
0067
0068
0069 if length(bs(1).data.y) ~= length(bs(2).data.y) || length(bs(1).data.x) ~= length(bs(2).data.x)
0070 error ('### The length of the data vectors must be the same.')
0071 end
0072
0073
0074 if ~isequal(bs(1).data.x, bs(2).data.x)
0075 error('### The two data series should have the same x values.');
0076 end
0077
0078
0079 if ismember('t0', fields)
0080 if bs(1).data.t0.utc_epoch_milli ~= bs(2).data.t0.utc_epoch_milli
0081 error('### The two data series don''t start at the same time.');
0082 end
0083 end
0084
0085
0086 if ismember('xunits', fields)
0087 if bs(1).data.xunits ~= bs(2).data.xunits
0088 error('### The two data series should have the same x units');
0089 end
0090 end
0091
0092
0093 bs(1).data.setY(complex(bs(1).data.y, bs(2).data.y));
0094 if ismember('yunits', fields)
0095 if bs(1).data.yunits ~= bs(2).data.yunits
0096 bs(1).data.setYunits(bs(1).data.yunits + bs(2).data.yunits*'i');
0097 end
0098 end
0099
0100
0101 bs(1).addHistory(getInfo, plist, ao_invars, [bs(1).hist bs(2).hist]);
0102
0103
0104 bs(1).setName(sprintf('complex(%s, %s)', ao_invars{1}, ao_invars{2}), 'internal');
0105
0106
0107 varargout{1} = bs(1);
0108 end
0109
0110
0111
0112
0113 function ii = getInfo(varargin)
0114 if nargin == 1 && strcmpi(varargin{1}, 'None')
0115 sets = {};
0116 pl = [];
0117 else
0118 sets = {'Default'};
0119 pl = getDefaultPlist;
0120 end
0121
0122 ii = minfo(mfilename, 'ao', '', 'Operator', '$Id: complex.m,v 1.16 2008/08/15 11:45:18 ingo Exp $', sets, pl);
0123 end
0124
0125
0126
0127
0128 function pl = getDefaultPlist()
0129 pl = plist();
0130 end
0131