I have used logical indexing before in MATLAB vectors for conditions like
X = X(X < 6);
Now however I would like to find local extrema using the same idea, but with "local" conditions. I would be interested in something like
X = X(X(i) > X(i-1) & X(i) > X(i + 1));
I know this wouldn't work in the first and last elements of the vector and that there are better ways to find local extrema.
This question is different from this previous one (Getting FFT peaks from data) in that I'm not specially interested in finding the maxima, but rather to be able to use logical indexing with "local" conditions referring to adjacent elements in the vector.