Comments

Pages

How to Detect Peak in MATLAB

Posted by at 5:39 AM Read our previous post

1. Define a data source by importing data into MATLAB. For example, create a sine wave with random noise:my_signal = sin(0:0.1:10) + rand(1,101);
2. Find peaks in your signal using the quadratic interpolation method of "findpeaks()":[peak_value, peak_location] = findpeaks(my_signal);
3. Search for peaks of a minimum height using the "minpeakheight" parameter. The height is a real-valued scalar that refers to the minimum data value of allowable peaks:[peak_value, peak_location] = findpeaks(my_signal,'minpeakheight',2.5);
4. Search for peaks separated by a minimum distance using the "minpeakdistance" parameter. The value is the minimum number of indices between peaks in the "my_signal" vector, and must be an integer:[peak_value, peak_location] = findpeaks(my_signal,'minpeakdistance',5);
5. Search only for peaks above a certain threshold using the "threshold" parameter. This is a real-valued scalar that refers to the minimum allowable difference between peak and adjacent data points:[peak_value, peak_location] = findpeaks(my_signal,'threshold',0.5);
6. Find only a certain number of peaks using the "npeaks" parameter. The value must be an integer:[peak_value, peak_location] = findpeaks(my_signal,'npeaks',5);
7. Sort the returned list of peaks using the "sortstr" parameter. Allowable values are "ascend," "descend" and "none":[peak_value, peak_location] = findpeaks(my_signal,'sortstr','ascend');

About