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.getY) ~= length(bs(2).data.getY) || length(bs(1).data.getX) ~= length(bs(2).data.getX)
0070 error ('### The length of the data vectors must be the same.')
0071 end
0072
0073
0074 if ~isequal(bs(1).data.getX, bs(2).data.getX)
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.getY, bs(2).data.getY));
0094 if ismember('yunits', fields)
0095 if bs(1).data.yunits == bs(2).data.yunits
0096 bs(1).setYunits(bs(1).data.yunits, 'internal');
0097 else
0098 error('### Can''t combine data with different units');
0099 end
0100 end
0101
0102
0103 bs(1).addHistory(getInfo, getDefaultPlist, ao_invars, [bs(1).hist bs(2).hist]);
0104
0105
0106 bs(1).setName(sprintf('complex(%s, %s)', ao_invars{1}, ao_invars{2}), 'internal');
0107
0108
0109 varargout{1} = bs(1);
0110 end
0111
0112
0113
0114
0115 function ii = getInfo(varargin)
0116 if nargin == 1 && strcmpi(varargin{1}, 'None')
0117 sets = {};
0118 pl = [];
0119 else
0120 sets = {'Default'};
0121 pl = getDefaultPlist;
0122 end
0123
0124 ii = minfo(mfilename, 'ao', '', utils.const.categories.op, '$Id: complex.m,v 1.22 2008/09/05 14:13:27 hewitson Exp $', sets, pl);
0125 end
0126
0127
0128
0129
0130 function pl = getDefaultPlist()
0131 pl = plist();
0132 end
0133