Working Kerr effect; PDM; speedups; removed unused files
[4yp.git] / phasenoise_AWGN.m
index f055bcc..621a33d 100644 (file)
@@ -1,11 +1,11 @@
-numSymbs = 5e3;
+numSymbs = 5e4;
 M = 4;
 rolloff = 0.5;
 
 Rsym = 2.5e10; % symbol rate (sym/sec)
 
 span = 6; % filter span
-sps = 4; % samples per symbol
+sps = 8; % samples per symbol
 
 fs = Rsym * sps; % sampling freq (Hz)
 Tsamp = 1 / fs;
@@ -48,15 +48,20 @@ linewidthTx = 0; % Hz
 linewidthLO = 5e6; % Hz
 %linewidthLO = Rsym * 1e-3;
 
-iterations = 25;
+iterations = 1;
 avgSa = 40;
 
+TsampOrig = Tsamp;
+
 for it = 1 : iterations
   [xPSKpn, pTxLoPSK] = phaseNoise(xPSK, linewidthTx, linewidthLO, Tsamp);
   [xDEPSKpn, pTxLoDEPSK] = phaseNoise(xDEPSK, linewidthTx, linewidthLO, Tsamp);
   [xDPSKpn, pTxLoDPSK] = phaseNoise(xDPSK, linewidthTx, linewidthLO, Tsamp);
 
   for i = 1:plotlen
+    Tsamp = TsampOrig;
+    sps = 8;
+
     snr = EbN0_db(i) + 10 * log10(log2(M)) - 10 * log10(sps);
     noiseEnergy = 10 ^ (-snr / 10);
 
@@ -68,9 +73,12 @@ for it = 1 : iterations
     rDEPSK = rxFilter(yDEPSK, rolloff, span, sps);
     rDPSK = rxFilter(yDPSK, rolloff, span, sps);
 
-    rPSKSamp = rPSK(sps*span/2+1:sps:(numSymbs+span/2)*sps);
-    rDEPSKSamp = rDEPSK(sps*span/2+1:sps:(numSymbs+span/2)*sps);
-    rDPSKSamp = rDPSK(sps*span/2+1:sps:(numSymbs+span/2)*sps);
+    sps = 2;
+    Tsamp = TsampOrig * 4;
+
+    rPSKSamp = rPSK(1:2:end);
+    rDEPSKSamp = rDEPSK(1:2:end);
+    rDPSKSamp = rDPSK(1:2:end);
 
     [rPSKSampEq, phiestsPSK] = phaseNoiseCorr(rPSKSamp, M, pi/M, avgSa);
     [rDEPSKSampEq, phiestsDEPSK] = phaseNoiseCorr(rDEPSKSamp, M, 0, avgSa);
@@ -99,7 +107,7 @@ for it = 1 : iterations
 
     if EbN0_db(i) == 8 && it == 1
       figure(1234);
-      plot(repelem(-phiestsPSK, sps));
+      plot(repelem(-phiestsPSK, 8));
       hold on;
       plot(pTxLoPSK);
       legend('estimate', 'actual');