Commit 2ac543ca authored by Jan-Gerrit Richter's avatar Jan-Gerrit Richter

fixed crash if roots are imaginary in start_IR

parent f25aef72
......@@ -120,7 +120,11 @@ for iChannel = 1:input.nChannels
[~, ind] = max(abs(Y));
y = imag(Y(ind-n:ind+n));
p = polyfit((-n:n)',y,N);
r = roots(p);
r = r(abs(r) == min(abs(r)));
sampleStart(iChannel) = ind + r - input.nSamples;
if sum(p < 0) == 0
r = roots(p);
r = r(abs(r) == min(abs(r)));
sampleStart(iChannel) = ind + r(1) - input.nSamples;
else
sampleStart(iChannel) = 0;
end
end
\ No newline at end of file
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