Commit fecc8c01 authored by Markus Mueller-Trapet's avatar Markus Mueller-Trapet

fix the bugfix for imaginary roots for correlation mode

parent 5642c9ed
...@@ -120,10 +120,10 @@ for iChannel = 1:input.nChannels ...@@ -120,10 +120,10 @@ for iChannel = 1:input.nChannels
[~, ind] = max(abs(Y)); [~, ind] = max(abs(Y));
y = imag(Y(ind-n:ind+n)); y = imag(Y(ind-n:ind+n));
p = polyfit((-n:n)',y,N); p = polyfit((-n:n)',y,N);
if sum(p < 0) == 0 r = roots(p);
r = roots(p); if all(isreal(r))
r = r(abs(r) == min(abs(r))); r = r(abs(r) == min(abs(r)));
sampleStart(iChannel) = ind + r(1) - input.nSamples; sampleStart(iChannel) = ind + r - input.nSamples;
else else
sampleStart(iChannel) = 0; sampleStart(iChannel) = 0;
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment