# Remove the extra peaks by lag

Suppose that we have some peaks of a signal and we know the time lag between dominant peaks. How is it possible to remove the extra peaks by applying time lag ? Lets say it in MATLAB

[corr]=xcorr(signal,signal);
[val1 ind1]=max(corr);
corr(ind1:length(corr))=0; % symetric properties of correlation
[val2 ind2]=max(corr);
lag=ind1-ind2;
[pks ind]=findpeaks(signal);


Actually, I would like to remove the spurious peaks by using time-lag but maybe some dominant peaks a little less or more than exact time-lag.

• The code does not work standalone since it requires "signal" to have a certain value. Right now no one knows what "signal" is, how the desired peaks look like and how the undesired peaks look like. This makes it very difficult to give you an informed answer. Please update your question and include code to define "signal" or add some plots where you mark which peaks you want and which not. Ideally, you do both. Put some effort in your questions, please. – jan Nov 27 '13 at 11:22
• Dear jan I cannot update photo because My reputationis not enough.sorry The signal is LP residual and I want to extract Glottal closure from it. – amir ghasemi Nov 27 '13 at 13:50
• Upload the photo to imgur and post the link and someone will edit it into the question for you. – jonsca Nov 28 '13 at 0:05
• How many samples length of one peak? If the length of peak is a few samples, you can use some nonlinear filtering (median?) – SergV Nov 28 '13 at 5:07
• Every peak may has 1 or more samples. but I want to remove the spurious peaks by time-lag. – amir ghasemi Nov 29 '13 at 2:43