local maxima \ minima

버전 1.0.0.0 (1.05 KB) 작성자: Yonathan Nativ
a simple (but effective) code to find local maximas
다운로드 수: 14.3K
업데이트 날짜: 2007/9/20

라이선스 없음

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.

use examples:
a = cumsum(randn(1000,1));
peaks = localMaximum(a,[100]);
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;
plot3(x(lMaxInd),y(lMaxInd),a(lMaxInd),'k*','markersize',10,'linewidth',1.5);
plot3(x(lMinInd),y(lMinInd),a(lMinInd),'g*','markersize',10','linewidth',1.5);
legend('sinc(x)sinc(y)','peaks','valleys','location','best')

P.S
- It is recommended to run (if possible) a LPF on the data before searching for the peaks

인용 양식

Yonathan Nativ (2024). local maxima \ minima (https://www.mathworks.com/matlabcentral/fileexchange/14498-local-maxima-minima), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R14SP2
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0

I added an option to exclude plateau points - I do it by adding noise which won't affect the real peaks position. As it is rather heavy you might not want to use this (default option is off).