how to write a detection algorithm for the peaks of a signal
25 views (last 30 days)
i have to load a GSR signal in Matlab and then i have to process it...for that i need to write a code to detect the peaks of the signal but i don t know how to do that...i need some links or files (or an example code) that can help me with that...THANKS!!!
Image Analyst on 5 Apr 2020
Try findpeaks() if you have the Signal Processing Toolbox:
[peakValues, indexesOfPeaks] = findpeaks(gsrSignal);
plot(indexesOfPeaks, peakValues, 'rv', 'MarkerSize', 15);
If you don't get what you like, then there are lots of options for findpeaks to tweak how it finds the peaks.
Peng Li on 5 Apr 2020
That depends on what exactly you meant by peaks of a signal. If you want to have all local maximums, the easiest way I think is to apply a first order difference. If y is your signal, diff(y) is the first order forward difference.
dy = diff(y);
A local maxima is corresponding to the point that its two corresponding differences are with different signs.
index = find(dy(1:end-1) .* dy(2:end) < 0);
This is just an example of a working algorithms. You may need to modify here and there to meet you actual needs.