matlab - determine index and value of first negative peak -
i solving funcion uses moving average filter remove noise. how can determine index , value of first , second negative peak after apply filter input data?
use findpeaks on negative of data, extract first 2 elements extract first , second indices of negative peaks located. supposing signal stored in f, do:
[peaks, locs] = findpeaks(-f); p = peaks(1:2); loc = locs(1:2); findpeaks works finding local maxima. if want find local minima (i.e. negative peaks), apply findpeaks negative of signal local minima become local maxima, apply same algorithm. loc contain first 2 locations of negative peaks are, while p determine negative peak amplitudes.
however, you'll need play around input parameters findpeaks, instead of using default ones suit data, should enough started.
sidenote
if don't have access findpeaks, take @ this post wrote find peaks fft data. data different, overall logic same. however, finds all peaks - both local maxima , minima. if want find minima, @ negative of signal rather absolute value.
Comments
Post a Comment