Q:
I want to find blocks of values of ascending order within a vector. e.g.:
[... 10 1 2 3 4 5 56 ...]
and [1 2 3 4 5] should be recognized.
it should also recognise e.g.:
[... 100 50 51 52 53 54 20 ...]
A:
% if not care about precisely 5 number block;
strfind(diff(x), [1 1 1 1])
% if has to be 5 consecutive number;
strfind(diff(x) == 1,[0 1 1 1 1 0])+1
1 comment:
Hey Siyi,
I had the same issue and solved it this way:
locations = strfind(x', template);
Cheers
Post a Comment