using the correct XOR in MATLAB helps, but does not solve the problem