フィルターのクリア

I am trying to translate a find_peaks function call in python to matlab and they use a max threshold

10 ビュー (過去 30 日間)
Hi,
I am using matlab to recreate a script done in python. They use the python function find_peaks, which is very similar as the Matlab function.
One major difference is that when using the threshold specification, Matlab only has a minimum threshold option, whilst in python it is also possible to insert a max threshold.
Does anybody know how to implement using a max threshold in findpeaks in matlab?
Python example: find_peaks(sig, distance=distance, threshold=(None, 5.0), prominence=(20, None))
Thanks a lot in advance!!

採用された回答

Star Strider
Star Strider 2022 年 3 月 28 日
There is no 'MaxPeakHeight' so impose the maximum condition after the findpeaks call to limit the maximum peak values considered.
t = linspace(0, 10);
sig = sum(sin((1:2:9)'*2*pi*t));
[pks1,locs1] = findpeaks(sig);
figure
plot(t, sig)
hold on
plot(t(locs1), pks1, '^r')
hold off
grid
title('Plot All Peaks')
Lv = (pks1 <= 3); % Logical Vector To Keep Peaks <= 3
figure
plot(t, sig)
hold on
plot(t(locs1(Lv)), pks1(Lv), '^r')
hold off
grid
title('Plot Only Peaks <= 3')
There may be other ways to do this. I chose the ‘logical vector’ approach.
.
  2 件のコメント
Mette Dittmann
Mette Dittmann 2022 年 3 月 30 日
Thanks a lot! that makes great sense!
Star Strider
Star Strider 2022 年 3 月 30 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by