I want to sum consecutive 1 values given a logical input vector. An example of input and output is below. Notice that the output is the sum of the previous elements that were 1 and if a zero element is encountered, the sum starts over. I am trying to avoid a for loop here if I can. Suggestions?
Input Output0 00 00 01 10 01 10 00 01 11 21 31 40 01 10 01 11 20 0
Best Answer