0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 function res = applyoperator(as, ao_invars, op, opsym, pl, info)
0019
0020
0021 res = as(1);
0022
0023
0024 for j=2:numel(as)
0025
0026
0027 utils.helper.msg(2, 'applying %s to %s and %s', op, res.name, as(j).name);
0028
0029
0030 yu1 = res.data.yunits;
0031 yu2 = as(j).data.yunits;
0032 res.data = applyoperator(res.data, as(j).data, pl, plist('op', op));
0033
0034
0035 res.addHistory(info, pl, [{res.name} ao_invars(j)], [res.hist as(j).hist]);
0036
0037
0038 if (length(opsym) == 2 && opsym(1) == '.') || ...
0039 (length(opsym) == 1)
0040 res.setName(['(' res.name ')' opsym '(' ao_invars{j} ')'], 'internal');
0041 else
0042 res.setName([opsym '(' res.name ',' ao_invars{j} ')'], 'internal');
0043 end
0044
0045 if any(strcmp(op, {'plus', 'minus'}))
0046 if isempty(res.data.yunits.strs)
0047 res.setYunits(as(j).data.yunits);
0048 elseif isempty(as(j).data.yunits.strs)
0049
0050 elseif res.data.yunits ~= as(j).data.yunits
0051 error(['### You can not apply ' opsym ' to data with different Y units']);
0052 end
0053 elseif ismethod('unit', op)
0054
0055 if any(strcmp(op, {'mpower', 'power'}))
0056 res.setYunits(feval(op, yu1, as(j).data.getY), 'internal');
0057 else
0058 res.setYunits(feval(op, yu1, yu2), 'internal');
0059 end
0060 else
0061 warning('LTPDA:INFO', '### This method doesn''t exist in the units class. Please set the units yourself.');
0062 end
0063
0064 end
0065
0066 end
0067