The matlab FAQ describes a one-line method for finding the local maximas:
index = find( diff( sign( diff([0; x(:); 0]) ) ) < 0 );
But I believe this only works if the data is more or less smooth. Suppose you have data that jumps up and down in small intervals but still has some approximate local maximas. How would you go about finding these points? You could divide the vector into n pieces and find the largest value not on the edge of each but there should be a more elegant and faster solution.
A one-line solution would be great, too.
Edit: I'm working with noisy biological images which I am attempting to divide into distinct sections.
Depending on what you want, it's often helpful to filter the noisy data. Take a look at MEDFILT1, or using CONV along with FSPECIAL. In the latter approach, you'll probably want to use the 'same' argument to CONV and a 'gaussian' filter created by FSPECIAL.
After you've done the filtering, feed it through the maxima finder.
EDIT: runtime complexity
Let's say the input vector has length X and the filter kernel length is K.
The median filter can work by doing a running insertion sort, so it should be O(XK + K log K). I have not looked at the source code and other implementations are possible, but basically it should be O(XK).
When K is small, conv uses a straight-forward O(X*K) algorithm. When X and K are nearly the same, then it's faster to use a fast fourier transform. That implementation is O(X log X + K log K). Matlab is smart enough to automatically choose the right algorithm depending on the input sizes.