On 6/14/2014 7:46 AM, Andrew wrote:
> "Roger Stafford" wrote in message
> <kccqvo$etb$1@newscl01ah.mathworks.com>...
>> max plank <avrialony@gmail.com> wrote in message
>> <5f1a24c9122c4cf79ab4d816839abc2c@googlegroups.com>...
>> > Let us define vector y = [0 0 0 1 1 1 1 0 0 0 1 1 0]
>> > I would like to extract the length of the continuous line
>> > (i.e: ones = [4,2], zeros = [3,3,1])
>>           d = diff([0,find(diff(x)~=0),length(x)]);
>> Zeros = d((x(1)>0)+1:2:end);
>> Ones = d((x(1)<1)+1:2:end);
...
> Can this be applied to vectors that are not binary for example y = [0 0
> 0 1 1 2 2 2 3 4 4]?
W/ some modifications, sure. The diff() operation will find the
breakpoints between sections; just that there will be one for every
level change and the levels themselves aren't known w/o further analysis
of the underlying data values...

