how to write a detection algorithm for the peaks of a signal
7 次查看(过去 30 天)
显示 更早的评论
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!!!
0 个评论
回答(2 个)
Image Analyst
2020-4-5
Try findpeaks() if you have the Signal Processing Toolbox:
[peakValues, indexesOfPeaks] = findpeaks(gsrSignal);
plot(gsrSignal, 'b-');
hold on;
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.
0 个评论
Peng Li
2020-4-5
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!