I have a waveform, in which I have determined a specific point (green star on plot below) with a criteria. I would like now to find the location of the next peak (could be a maxima or minima) on the right of this point (e.g red circle on plot below, in that case, it is a minima) automatically. Note that I will run this on multiple waveforms, with different peak heights/noise content.
Tried the function findpeaks()
but cannot really get it to work! Any help will be greatly appreciated.
EDITED after answer from user3288586 New code, working:
prominence_factor = 0.1
[peakPos , locPos] = findpeaks (signal,time,'Npeaks',1,'MinPeakProminence', prominence_factor);
[peakNeg, locNeg] = findpeaks (-signal,time, 'Npeaks', 1, 'MinPeakProminence', prominence_factor);
You can run findpeaks twice. First with original signal and then with the inverted signal. To invert the signal you can do this:
inverted_signal = 2*mean(original_signal) - original_signal
Then see which peak is the closest. Peaks in the inverted signal will of course denote the minima.