1 function s = sumbitxor(a,b)
3 if ~isvector(a) || ~isvector(b)
4 roboerror('wrongInput','Both inputs must be vectors');
10 L = numel(a)-numel(b);
12 [b,a] = deal(a,b); % swap variables in place
16 nomem = warning('error','MATLAB:nomem'); %
#ok<CTPCT> Change error to warning 18 s = uint32(xcorr(
double(a),
double(~b),L))+uint32(xcorr(
double(~a),
double(b),L));
21 warning(nomem); % re-enable as error
22 switch exception.identifier
28 s = zeros(L+1,1,
'uint32');
30 s(ptr) = nnz(xor(a(ptr+(1:N)),b));
41 function x = parseinput(x)
43 roboerror('wrongInput','Both inputs must be vectors');
45 if ~isnumeric(x) || ~all(x==0 | x==1)
46 roboerror('wrongInput','Input must be a numeric vector with zeros or ones only.');
47 elseif verLessThan('matlab', '8.4.0') % Trick to save memory
48 % Before MATLAB R2014b, input to xcorr must be
double 51 % Since MATLAB R2014b, input to xcorr can be uint8