Ali - if you want to determine where the next interval should begin, you could consider the difference between each element. When the difference is greater than 0.1, you would know that that is the start of a new interval. Use the diff command for that. With your x from above, we could do intervallStartIdcs = [1 find(diff(x)>0.1)+1];
We calculate the difference between each consecutive element using diff. We then then use find to determine the indices in that difference vector of values (differences) greater than 0.1. As the difference vector has one less element than x, we add one to each of those indices. We then prefix this vector of indices with 1 which will correspond to the first interval. In this case, we get an answer of
1
4
8
16
22
26
30
43
48
53
57
62
66
76
80
86
95
100
109
A quick glance at some of the values does show that new intervals begin at 1, 4, 8, etc. from our vector x.
Best Answer