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

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] ?

 Accepted 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.

More Answers (0)

Categories

Find more on Powertrain Blockset in Help Center and File Exchange

Asked:

on 13 Dec 2017

Commented:

on 13 Dec 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!