How can I find consecutive ones and the number of ones in each block?
58 views (last 30 days)
Tasi on 4 Mar 2015
I have an example variable defined as x=[5 1 1 1 1 1 7 1 1 5]; I would like to get the number of ones in each block of consecutive ones, so that my output would look like this: [5 2]. Is there a way to do write a command so that is valid in a loop in which the variable changes both its values and length? Thanks.