I have a set of 1s and 0s. How do I count the maximum number of consecutive 1s?
(For example, x = [ 1 1 0 0 1 1 0 0 0 1 0 0 1 1 1 ....]). Here the answe
x = [ 1 1 0 0 1 1 0 0 0 1 0 0 1 1 1 ....]
Another possibility:
x = randi([0 1], [1 100]); %# random 0/1 vector d = diff([0 x 0]); maxOccurence = max( find(d<0)-find(d>0) )
which is inspired by an answer to a somewhat similar question...