Chromatic dispersion and line width phase noise
[4yp.git] / chromaticDispersion1Signal.m
diff --git a/chromaticDispersion1Signal.m b/chromaticDispersion1Signal.m
new file mode 100644 (file)
index 0000000..db25965
--- /dev/null
@@ -0,0 +1,63 @@
+M = 4;
+numSymbs = 1000;
+
+%% https://www.mathworks.com/help/comm/examples/passband-modulation-with-adjacent-channel-interference.html
+Rsym = 2.5e10; % symbol rate (sym/sec)
+
+span = 6; % Tx/Rx filter span
+rolloff = 0.25; % Tx/Rx RRC rolloff
+sps = 4; % samples per symbol
+
+
+fs = Rsym * sps; % sampling freq (Hz)
+Tsamp = 1 / fs;
+
+t = (0 : 1 / fs : numSymbs / Rsym + (1.5 * span * sps - 1) / fs)';
+
+
+data = randi([0 M - 1], numSymbs, 1);
+modData = pskmod(data, M, 0, 'gray');
+x = txFilter(modData, rolloff, span, sps);
+
+%% Simulate chromatic dispersion
+D = 20; % ps / (nm km)
+lambda = 1550; % nm
+z = 1000; % km
+
+[xCD, xCDkstart] = chromaticDispersion(x, D, lambda, z, Tsamp);
+xCD = normalizeEnergy(xCD, numSymbs, 1);
+
+
+y = xCD;
+
+
+yCDComp = CDCompensation(y, D, lambda, z, Tsamp);
+
+%% Compare original signal and compensated signal
+figure(1);
+subplot(211);
+plot(real(x(1:300)));
+hold on
+plot(real(yCDComp(1:300)));
+hold off
+title('Real part');
+legend('original', 'dispersion compensated');
+subplot(212);
+plot(imag(x(1:300)));
+hold on
+plot(imag(yCDComp(1:300)));
+hold off
+title('Imag part');
+
+
+r = rxFilter(yCDComp, rolloff, span, sps);
+r = normalizeEnergy(r, numSymbs, 1); % Add noise energy if needed
+
+rSampled = r(sps*span/2+1:sps:(numSymbs + span/2) * sps);
+
+scatterplot(modData);
+title('Constellation of original modulation');
+scatterplot(rSampled);
+title('Constellation of sampled received waveform');
+
+demodData = pskdemod(rSampled, M, 0, 'gray');