Info

This question is closed. Reopen it to edit or answer.

Use findpeaks function for latency assessment

1 view (last 30 days)
Anton M
Anton M on 10 May 2022
Closed: Anton M on 10 May 2022
Hello,
I am trying to use the findpeaks function to measure the latency of my trigger signal (first channel) and my sound signal (second channel). The problem is that, particularly for my second channel, there are loads of peaks (there are trains of five vowels). I only need the x value of the first initial small peak of each vowel train as this would be the onset of the sound which I would need to compare to the trigger latency.
I know that the first small peak occurs approximately every 1000 miliseconds and I tried to insert 1000 as MinPeakDistance but I get this error message:
Error using findpeaks
Expected MinPeakDistance to be a scalar with value < 0.999994.
Error in findpeaks>parse_inputs (line 339)
validateattributes(Pd,{'numeric'},{'real','scalar','nonempty','nonnegative','<',x(M)-x(1)},'findpeaks','MinPeakDistance');
Error in findpeaks (line 136)
= parse_inputs(isInMATLAB,Yin,varargin{:});
I dont understand why MinPeakDistance needs to be less than 0.99. Does anybody know an alternative solution for this?
Thank you!
%% Select sample of recording for visualisation
Sample = 160000
SecondChS = SecondCh(1:Sample,:);
FirstChS = FirstCh(1:Sample,:)
XS = NewX(1:Sample);
%%Top plot
nexttile
plot(XS,FirstChS)
title('First Channel')
%Bottom plot
nexttile
plot(XS,SecondChS)
title('Second Channel')
[pks,locs] = findpeaks(SecondChS,Sample,'MinPeakProminence',0.01,'Annotate','extents','MinPeakDistance',1000);

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!