I am trying to translate a find_peaks function call in python to matlab and they use a max threshold
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Mette Dittmann
il 28 Mar 2022
Commentato: Star Strider
il 30 Mar 2022
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!!
0 Commenti
Risposta accettata
Star Strider
il 28 Mar 2022
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 Commenti
Star Strider
il 30 Mar 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Call Python from MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

