MATLAB: How to find repeat element of vector

loopmatrixrepeat

Suppose, i have a matrix b=[1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1] and i want to find the repeated element of this matrix by 3 times using for loop . as the new matrix will be a=[1 0 1 1 0 0 1 1] . How easily can solve using for loop ??

Best Answer

for i=1
a=b(1:3:end);
end