I have the following vector in matlab:
[1 0 1 1 1 0 0 1 1 0 1 1 1]
I want to be able to find the longest consecutive set of 1's (so in this case it would be 3) and then print the index where this set arises (3
and 5
).
In this scenario 1 1 1
shows up twice, I would like it to make sure it prints the index of where the first set is.
What coding can I use for this - but without using any in-built matlab functions, only for loops.