local maxima \ minima (Scripts) Publisher's description
from Yonathan Nativ
This is a very simple function to find the local maximum in any dimensional array.
This is a very simple function to find the local maximum in any dimensional array. As simple as it is it still gives nice results.
I use the imdilate() function as a maximum operation and then compare the data to the result.
The function receives three parameters:
the data, a vector defining the minimum distance between peaks in each of the data dimensions. and a flag either to exclude equal points or not.
a = cumsum(randn(1000,1));
peaks = localMaximum(a,);
figure; plot(a); hold on; plot(peaks,a(peaks),'ro');
[x y] = meshgrid(-6:0.1:6,-6:0.1:6);
a = sinc(x).*sinc(y);
lMaxInd = localmaximum(a,[20 20]);
lMinInd = localMaximum(-a,[20 20]);
figure; mesh(x,y,a); hold on;
- It is recommended to run (if possible) a LPF on the data before searching for the peaks
System Requirements:MATLAB 7.0.4 (R14SP2)
Program Release Status: Major Update
Program Install Support: Install and Uninstall