Suppose I have a binary vector
X = [0 0 0 0 1 1 1 0 1 1 1 1]
I want to characterize each element with the number of identical elements occurring in consecutive positions in both the directions. For instance, the desired output should look like:
Y = [4 4 4 4 3 3 3 1 4 4 4 4].
I found a similar thread, but it counts only in the forward direction. Thanks in advance for any sort of assistance.
Best Answer