Clear Filters
Clear Filters

How to find troughs of a signal below a threshold

9 views (last 30 days)
I am trying to find troughs of a signal which are below a certain threshold
I tried findpeaks but its not working
Is there any thresholding option for islocalmin function?
  1 Comment
Jan on 6 Mar 2023
What are "throughs of a signal"? What does "is not working" mean explicitly?

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 6 Mar 2023
Use the 'MinPeakHeight' name-value pair —
t = linspace(0, 2*pi, 500);
s = sin(2*pi*t) - sin(2*pi*0.1*t-0.45);
Threshold = -1.75;
[pks,locs] = findpeaks(-s, 'MinPeakHeight',-Threshold)
pks = 1×2
1.9576 1.9443
locs = 1×2
220 298
plot(t, s)
hold on
plot(t(locs), s(locs), 'vr', 'MarkerFaceColor','r')
hold off
ylim([-2.5 1.5])
yline(Threshold, '--m', 'Threshold')

Community Treasure Hunt

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

Start Hunting!