Does findpeaks have a threshold option?

38 ビュー (過去 30 日間)
Bristin Rustenbeck
Bristin Rustenbeck 2016 年 7 月 7 日
回答済み: HUGO SILVA 2017 年 8 月 3 日
I have a plot with several maximums of differing heights. I want to find the values/locations of one of the middle peaks, which is neither the highest nor the shortest peak in the graph. Is there a way to use findpeaks to specify a certain height threshold? In other words, find peaks between heights y1 and y2?

採用された回答

Star Strider
Star Strider 2016 年 7 月 7 日
‘find peaks between heights y1 and y2’
That option doesn’t exist, but you can do something similar with two separate findpeaks calls and a setdiff call. I don’t have your data, but the code would be something like this:
x = linspace(0, 5*pi, 250);
y = 0.25*sin(x).*(0.1*cos(5*x));
[pks1,locs1] = findpeaks(y, x, 'MinPeakHeight',0.01);
[pks2,locs2] = findpeaks(y, x, 'MinPeakHeight',0.02);
[C, ia] = setdiff(locs1, locs2, 'stable');
MidPks = [pks1(ia); locs1(ia)];
figure(1)
plot(x, y)
hold on
plot(MidPks(2,:), MidPks(1,:), '^r')
hold off
grid

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 7 日
Look at the help, you will find what you need http://www.mathworks.com/help/signal/ref/findpeaks.html

HUGO SILVA
HUGO SILVA 2017 年 8 月 3 日
Excelent sugestion Star Strider. I was looking for a code like your, and I finded it, but it worked for some situation.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by