image thumbnail

peakfinder(x0, sel, thresh, extrema, includeEndpoints, interpolate)

version 2.0.2.0 (10.9 KB) by Nathanael Yoder
Quickly finds local maxima (peaks) or minima (valleys) in a noisy signal.

36.4K Downloads

Updated 02 Oct 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

This function quickly finds local peaks or valleys (local extrema) in a noisy vector using a user defined magnitude threshold to determine if each peak is significantly larger (or smaller) than the data around it. The problem with the strictly derivative based peak finding algorithms is that if the signal is noisy many spurious peaks are found. However, more complex methods often take much longer for large data sets, require a large amount of user interaction, and still give highly variable results.
This function attempts to use the alternating nature of the derivatives along with the user defined threshold to identify local maxima or minima in a vector quickly and robustly. The function is able to correctly identify the major peaks on a 1.5 million data point noisy sum of sinusoids in under a second as is shown in the example in the code comments.
Please don't hesitate to comment or contact me if you have suggestions about improvements that could be made to this function.

Cite As

Nathanael Yoder (2021). peakfinder(x0, sel, thresh, extrema, includeEndpoints, interpolate) (https://www.mathworks.com/matlabcentral/fileexchange/25500-peakfinder-x0-sel-thresh-extrema-includeendpoints-interpolate), MATLAB Central File Exchange. Retrieved .

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

Inspired: voigt line shape fit

Community Treasure Hunt

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

Start Hunting!