# How to use findpeaks to find the maximum for a stimulus that contains multiple events?

12 views (last 30 days)
steamrice on 10 Feb 2020
Commented: Star Strider on 4 Mar 2020
Hi, I am wondering if I have a signal that contains mulitple events. Is it possbile to locate the the max peak for each event (see the attached picture) by uaing findpeaks? Thanks in advance

Star Strider on 10 Feb 2020
I would first use findchangepts (R2016a and later) to segment the signal, then use findpeaks on each segment.

steamrice on 4 Mar 2020
Another thing if you don't mind, I was trying the Ipc method:
segmentlen = 100;
noverlap = 90;
NFFT = 128;
spectrogram(FT_af (:,1),segmentlen,noverlap,NFFT,Fs,'yaxis')
title('Signal Spectrogram')
dt = 1/Fs;
I0 = round(0.1/dt);
Iend = round(0.25/dt);
x = (I0:Iend);
x1 = x.*hamming(length(x));
preemph = [1 0.63];
x1 = filter(1,preemph,x1);
A = lpc(x1,6);
rts = roots(A);
rts = rts(imag(rts)>=0);
angz = atan2(imag(rts),real(rts));
[frqs,indices] = sort(angz.*(Fs/(2*pi)));
bw = -1/2*(Fs/(2*pi))*log(abs(rts(indices)));
nn = 1;
for kk = 1:length(frqs)
if (frqs(kk) > 90 && bw(kk) <400)
formants(nn) = frqs(kk);
nn = nn+1;
end
end
formants
I am having a trobule with A = lpc(x1,6);
Error using roots (line 23)
Input must be a vector.
Error in testingmethod(line 77)
rts = roots(A);
steamrice on 4 Mar 2020
My email comes up with a delay! But thanks for helping it throughout!
Star Strider on 4 Mar 2020
I have not used that function or explored that example. The roots function returns the roots of a polynomial, so the argument must be a vector of polynomial coefficients.

steamrice on 10 Feb 2020
Edited: steamrice on 10 Feb 2020
I attached my data sample if you have time to take a look? (The first two columns are voltage measuremnt whereas the third column is just a signal trigger)