Peak detection in matlab
A great function for peak detection in matlab is the peakfinder (downloadable at http://www.mathworks.com/matlabcentral/fileexchange/25500). Here's a set of super basic instructions regarding how to use this function (for people with little experience with matlab):
Setting up peakfinder
- Download the peakfinder package from the link above. extract/unzip the folder and put it in a folder under your matlab path
- In matlab, add the peakfinder folder to path (file -> set path, click on set path, select the peakfinder folder by browsing, click on save, then click on close)
Using peak finder
Assuming your signal is already in the matlab workspace called x, to find the peaks using peakfinder, type in the following in the matlab command window:
[peaks, locs] = findpeaks(x)
This would result in two vectors:
peaks = [# # # # # ... ] <-- indicates all the peaks that are found in x
locs = [# # # # # ...] <-- indicates all the locations/positions of the found peaks
To examine the peaks found using this setting, you can type in the following:
plot(x);
hold on;
plot(locs,peaks,'o','MarkerEdgeColor','r')
More functions/setting can be consulted through typing 'help peakfinder' in the matlab command window.
Labels: data analysis, Matlab, programming