MATLAB: How can i decode(unpack) an array of bits with a constant value

decoding bitsunpacking bits

For example; I have an array; [0 0 0 1 1 1 0 0 0]. and a constant value L= 3 how can i get the output as; [0 1 0] ?

Best Answer

Not sure what the "rule" really is for getting the bits. Maybe one of these?
x = your vector
L = your number
result = x(1:L:end);
or maybe
result = any(reshape(x,L,[]));
or maybe
result = all(reshape(x,L,[]));
If not one of the above, then maybe you could give us more details on the "rules" for the unpacking.