MATLAB: Xor operation using loop

binary operationsbitwise operationxor operation

i have 1 dimentional array say p=[1 0 1 0 1 1 1 0 0], now i want to xor its bits like
Q(l)= xor(p(i))…… where i=l,l+N,l+2n,l+3N………..upto i<10 And N=2 and 1<l<N
How to implement it in loop i dont understand..plz help me kindly

Best Answer

p=[1 0 1 0 1 1 1 0 0]
po=p(1:2:end)
out=po(1)
for k=2:numel(po)
out=xor(out,po(k))
end