Commit | Line | Data |
---|---|---|
1eeb62fb AIL |
1 | M = 4; |
2 | numSymbs = 1000; | |
3 | ||
4 | %% https://www.mathworks.com/help/comm/examples/passband-modulation-with-adjacent-channel-interference.html | |
5 | Rsym = 2.5e10; % symbol rate (sym/sec) | |
6 | ||
7 | span = 6; % Tx/Rx filter span | |
8 | rolloff = 0.25; % Tx/Rx RRC rolloff | |
9 | sps = 4; % samples per symbol | |
10 | ||
11 | ||
12 | fs = Rsym * sps; % sampling freq (Hz) | |
13 | Tsamp = 1 / fs; | |
14 | ||
15 | t = (0 : 1 / fs : numSymbs / Rsym + (1.5 * span * sps - 1) / fs)'; | |
16 | ||
17 | ||
18 | data = randi([0 M - 1], numSymbs, 1); | |
19 | modData = pskmod(data, M, 0, 'gray'); | |
20 | x = txFilter(modData, rolloff, span, sps); | |
21 | ||
22 | %% Simulate chromatic dispersion | |
23 | D = 20; % ps / (nm km) | |
24 | lambda = 1550; % nm | |
25 | z = 1000; % km | |
26 | ||
27 | [xCD, xCDkstart] = chromaticDispersion(x, D, lambda, z, Tsamp); | |
28 | xCD = normalizeEnergy(xCD, numSymbs, 1); | |
29 | ||
30 | ||
31 | y = xCD; | |
32 | ||
33 | ||
34 | yCDComp = CDCompensation(y, D, lambda, z, Tsamp); | |
35 | ||
36 | %% Compare original signal and compensated signal | |
37 | figure(1); | |
38 | subplot(211); | |
39 | plot(real(x(1:300))); | |
40 | hold on | |
41 | plot(real(yCDComp(1:300))); | |
42 | hold off | |
43 | title('Real part'); | |
44 | legend('original', 'dispersion compensated'); | |
45 | subplot(212); | |
46 | plot(imag(x(1:300))); | |
47 | hold on | |
48 | plot(imag(yCDComp(1:300))); | |
49 | hold off | |
50 | title('Imag part'); | |
51 | ||
52 | ||
53 | r = rxFilter(yCDComp, rolloff, span, sps); | |
54 | r = normalizeEnergy(r, numSymbs, 1); % Add noise energy if needed | |
55 | ||
56 | rSampled = r(sps*span/2+1:sps:(numSymbs + span/2) * sps); | |
57 | ||
58 | scatterplot(modData); | |
59 | title('Constellation of original modulation'); | |
60 | scatterplot(rSampled); | |
61 | title('Constellation of sampled received waveform'); | |
62 | ||
63 | demodData = pskdemod(rSampled, M, 0, 'gray'); |