X-Git-Url: https://adrianiainlam.tk/git/?p=4yp.git;a=blobdiff_plain;f=CDCompensation.m;h=9f01950d79fe1c90a62c19c4938002580db9b954;hp=1f3cc2c641e2b156e0213f38a03cb36f637c92fa;hb=5fae00773184080617ac022c07495d365975e0e1;hpb=427465905320390cebf3d247b8beace19387c70f diff --git a/CDCompensation.m b/CDCompensation.m index 1f3cc2c..9f01950 100644 --- a/CDCompensation.m +++ b/CDCompensation.m @@ -21,11 +21,20 @@ function [yCDComp, kstart] = CDCompensation(y, D, lambda, z, Tsamp) kstart = -floor(N/2); % h: FIR filter - h = sqrt(j * c * Tsamp^2 / (D * lambda^2 * z)) * ... - exp(-j * pi * c * Tsamp^2 * k .^ 2 / (D * lambda^2 * z)); + h = exp(-j * pi * c * Tsamp^2 * k .^ 2 / (D * lambda^2 * z)); + + len_fft = max(length(y), length(h)); + H = fft(h, len_fft); + Y = fft(y, len_fft); + + yCDComp = ifft(H.' .* Y); + l = (length(h) - 1) / 2; + if l > 0 + yCDComp = [yCDComp(l:end); yCDComp(1:l-1)]; + else + yCDComp = [yCDComp(end); yCDComp(1:end-1)]; + end - yCDComp = upfirdn(y, h); - yCDComp = yCDComp(N:end); % truncate filter transients end %% References %% [1]: S.J. Savory, Digital filters for coherent optical receivers, 2008.