1 function [yCDComp, kstart] = CDCompensation(y, D, lambda, z, Tsamp)
2 %% Chromatic dispersion compensation.
4 %% - y: received waveform with CD
5 %% - D: dispersion coefficient (ps / (nm km))
6 %% - lambda: wavelength (nm)
7 %% - z: length of fibre (km)
8 %% - Tsamp: sampling time (s)
10 %% - yCDComp: y after performing CD compensation
12 %% Convert everything to SI base units
15 lambda = lambda * 1e-9; % m
18 %% Implementing Eq. (9) in [1].
19 N = 2 * floor(abs(D) * lambda^2 * z / (2 * c * Tsamp^2)) + 1;
20 k = -floor(N / 2) : floor(N / 2);
24 h = exp(-j * pi * c * Tsamp^2 * k .^ 2 / (D * lambda^2 * z));
26 len_fft = max(length(y), length(h));
30 yCDComp = ifft(H.' .* Y);
31 l = (length(h) - 1) / 2;
33 yCDComp = [yCDComp(l:end); yCDComp(1:l-1)];
35 yCDComp = [yCDComp(end); yCDComp(1:end-1)];
40 %% [1]: S.J. Savory, Digital filters for coherent optical receivers, 2008.