If I have a vector
[ 1 2 7 8 3 9 4 7 2 5 7 8 9]
I want to find the longest segment of 'successive' numbers in this sequence.
In this example, the sequences would be:
[1 2 7 8], [3 9], [4 7], [2 5 7 8 9]
So the answer in this case will be
[2 5 7 8 9]
How can I do this using inbuilt matlab functions, and no for loops?
Best Answer