I am wondering how can I make findpeak
function detect the negative peaks not the positive ones, it detects the red peaks shown in the figure below and I need to detect the blue ones .. any ideas??
Many Thanks.
As mentioned, you have to use -data
.
Here is an example,
x = 0 : 1e-3 : 5*pi;
t = (0 : length(x)-1)*1e-3;
y = sin(x);
[p l] = findpeaks(y);
plot(t,y);hold on
plot(t(l),p,'ko','MarkerFaceColor','g');
[pn ln] = findpeaks(-y);
plot(t(ln),-pn,'ko','MarkerFaceColor','r');
gives,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With