version (3.32 KB) by Peter O'Connor
Find local peaks in a signal


Updated 2 May 2012

View License

Efficiently finds local maxima in a signal (NlogN time) - these are defined as points in which are the higher than any other point within a specified range.

Matlab's "findpeaks" has a slightly different definition in which peaks simply have to be spaced apart by some minimum distance, but do not have to be actual maxima in their region.

To see the difference:
[locs heights]=peakperformance(x,30); % Find all peaks that are the highest within 30 samples
[heights2 locs2]=findpeaks(x,'minpeakdistance',30);
clf; plot(x); hold all; plot(locs,heights,'*'); plot(locs2,heights2-.05,'*');
legend '' 'peakperformance' 'findpeaks'

Cite As

Peter O'Connor (2022). peakperformance (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!