function [yCDComp, kstart] = CDCompensation(y, D, lambda, z, Tsamp) %% Chromatic dispersion compensation. %% Params: %% - y: received waveform with CD %% - D: dispersion coefficient (ps / (nm km)) %% - lambda: wavelength (nm) %% - z: length of fibre (km) %% - Tsamp: sampling time (s) %% Output: %% - yCDComp: y after performing CD compensation %% Convert everything to SI base units c = 299792458; % m/s D = D * 1e-6; % s/m^2 lambda = lambda * 1e-9; % m z = z * 1e3; % m %% Implementing Eq. (9) in [1]. N = 2 * floor(abs(D) * lambda^2 * z / (2 * c * Tsamp^2)) + 1; k = -floor(N / 2) : floor(N / 2); kstart = -floor(N/2); % h: FIR filter 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 end %% References %% [1]: S.J. Savory, Digital filters for coherent optical receivers, 2008.