How to restrict the Max Peak Height of findpeaks

44 次查看(过去 30 天)
I've managed to set a minimum peak height when plotting some data and finding the peaks but is there a function I can ue to set a max peak height? I can't seem to find one.
As you can see the errors are quite large. My code is as follows:
figure(nF)
findpeaks(ResAcceltrim,'MinPeakDistance',300,'MinPeakHeight',pe);
pks=findpeaks(ResAcceltrim,'MinPeakDistance',300,'MinPeakHeight',pe);
pks=pks(1:20,1);

采纳的回答

Image Analyst
Image Analyst 2015-10-12
If you don't want it to find peaks higher than some amount, just set those elements equal to the min. Actually it would be better to find the peaks and then "fall down" the peaks until they turn up again and then interpolate in from both sides, but that's more complicated even though it would be better. Maybe this simple way will do the job for you:
minValue = min(yourSignal);
tallPeakIndexes = yourSignal > someThreshold; % Whatever value you want.
yourSignal(tallPeakIndexes) = minValue; % Or you can use someThreshold instead of minValue.
If that ends up finding spurious peaks at the edges of the flattened peak, then use the more robust second method I suggested.

更多回答(1 个)

dpb
dpb 2015-10-12
You're correct there is no such facility built into findpeaks--one would normally think a large peak would be agoodthing(tm), not something to be avoided.
You'll have to simply test and exclude results from the returned search that exceed the rest by some magnitude (either absolute or as a percentage). Typical tests for outliers might be a ploy to consider in doing so unless you have other ways to decide what is "noise".

Community Treasure Hunt

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

Start Hunting!

Translated by