MATLAB: Xoring bits within a vector

xor matrix vector

hi every one…. i'm having a binary matrix with [101101110011 ; 100110110101 ; 011110011001 ; 111100010010] and i want to XOR bit1 with bit3 , bit4 with bit6, bit 7 with bit9, bit 10 with bit 12 for the whole matrix, i try to loop it but it didn't work… help needed

Best Answer

Use space between the the 1's and 0's
M = [1 0 1 1 0 1 1 1 0 0 1 1 ; 1 0 0 1 1 0 1 1 0 1 0 1 ; 0 1 1 1 1 0 0 1 1 0 0 1 ; 1 1 1 1 0 0 0 1 0 0 1 0];
xor(M(:, 1:3:end), M(:, 3:3:end))