included calcs of Es/No to noise variance
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 11 Feb 2014 03:07:24 +0000 (03:07 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 11 Feb 2014 03:07:24 +0000 (03:07 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1398 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/test_qpsk.m

index 3ddd5b407bff52517b8b121fd23214e2a88d8c5f..c84c10153c47c8702b0cfddb071f59b752224ced 100644 (file)
@@ -76,7 +76,19 @@ function sim_out = ber_test(sim_in, modulation)
         Es = Esvec(ne);\r
         EsNo = 10^(Es/10);\r
     \r
-        variance = Fs/(2*Rs*EsNo);\r
+        % Given Es/No, determine the variance of a normal noise source:\r
+        %\r
+        %   Es = C/Rs where C is carrier power (energy per unit time) and Rs is the symbole rate\r
+        %   N  = NoB where N is the total noise power, No is the Noise spectral density is W/Hz\r
+        %        and B is the bandwidth of the noise which is Fs\r
+        %   No = N/Fs\r
+        %\r
+        % equating Es/No we get:\r
+        %\r
+        %   Es/No = (C/Rs)/(No/Fs)\r
+        %   No    = CFs/(Rs(Es/No))\r
+\r
+        variance = Fs/(Rs*EsNo);\r
         Terrs = 0;  Tbits = 0;  Ferrs = 0;\r
         printf("EsNo (dB): %f EsNo: %f variance: %f\n", Es, EsNo, variance);\r
 \r
@@ -129,8 +141,9 @@ function sim_out = ber_test(sim_in, modulation)
                tx_filt_log = [tx_filt_log tx_filt];\r
                \r
                % AWGN noise and phase/freq offset channel simulation\r
+               % 0.5 factor ensures var(noise) == variance , i.e. splits power betwen Re & Im\r
 \r
-               noise = sqrt(variance)*( randn(1,M) + j*randn(1,M) );\r
+               noise = sqrt(variance*0.5)*( randn(1,M) + j*randn(1,M) );\r
                noise_log = [noise_log noise];\r
                rx_baseband = tx_filt.*exp(j*phase_offset) + noise;\r
                phase_offset += w_offset;\r
@@ -152,10 +165,6 @@ function sim_out = ber_test(sim_in, modulation)
                s_ch(k) = rx_filt;               \r
             end\r
 \r
-            %noise = sqrt(variance)*( randn(1,Nsymb) + j*randn(1,Nsymb) );\r
-            %s_ch = s_ch.*exp(j*phase_offset) + noise;\r
-            %phase_offset += w_offset;\r
-\r
             % Channel simulation\r
 \r
             if hf_sim\r
@@ -263,7 +272,7 @@ function two_bits = qpsk_demod(symbol)
     two_bits = [bit1 bit0];\r
 endfunction\r
 \r
-% Start simulation ---------------------------------------\r
+% Start simulations ---------------------------------------\r
 \r
 sim_in.Esvec            = 1:10; \r
 sim_in.Ntrials          = 100;\r
@@ -285,7 +294,7 @@ sim_in.w_offset         = 0;
 %sim_qpsk_coh            = ber_test(sim_in, 'qpsk');\r
 \r
 sim_in.phase_offset     = 0;\r
-sim_in.phase_est        = 0;\r
+sim_in.phase_est        = 1;\r
 sim_in.w_offset         = 0;  \r
 sim_in.plot_scatter     = 1;\r
 sim_in.Esvec            = 7;\r
@@ -296,7 +305,7 @@ figure(1);
 clf;\r
 semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec)\r
 hold on;\r
-semilogy(sim_qpsk.Ebvec, sim_qpsk.BER_theoryvec,'r;coherent;')\r
+semilogy(sim_qpsk.Ebvec, sim_qpsk.BER_theoryvec,'r;theory;')\r
 %semilogy(sim_qpsk_coh.Ebvec, sim_qpsk_coh.BERvec,'r;coherent;')\r
 hold off;\r
 xlabel('Eb/N0')\r