rate Fs simulation working Ok and graphs drawing OK with HF channel
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 6 Apr 2014 10:23:14 +0000 (10:23 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 6 Apr 2014 10:23:14 +0000 (10:23 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1490 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/test_dqpsk2.m

index 67f699f79ec90c31af46ac8612b1b62c935d0fde..01f456777910e9d7aa00917b5bf4cc2b092fb73f 100644 (file)
@@ -112,9 +112,9 @@ function sim_out = ber_test(sim_in)
 \r
         sc = 1; hf_n = 1;\r
         hf_sim_delay_line = zeros(1,M+Nhfdelay);\r
-        freq_sample = Fcentre + ((Fsep*(-Nc/2)):50:(Fsep*(Nc/2)));\r
-        freq_sample = (2*pi/Fs)*freq_sample;\r
-        hf_model = ones(Ntrials*Nsymb/Nc, length(freq_sample));   % defaults for plotting surface\r
+        freq_sample_hz = Fcentre + ((Fsep*(-Nc/2)):50:(Fsep*(Nc/2)));\r
+        freq_sample_rads = (2*pi/Fs)*freq_sample_hz;\r
+        hf_model = ones(Ntrials*Nsymb/Nc, length(freq_sample_rads));   % defaults for plotting surface\r
 \r
         % bunch of outputs we log for graphing\r
 \r
@@ -146,6 +146,7 @@ function sim_out = ber_test(sim_in)
 \r
             % Now we start processing frame Nc symbols at a time to model parallel carriers\r
 \r
+            tx_fdm_sym_log = [];\r
             for i=1:Nc:Nsymb\r
 \r
                 % Delay tx symbols to match delay due to filters. qpsk\r
@@ -200,12 +201,14 @@ function sim_out = ber_test(sim_in)
 \r
                    % sample HF channel spectrum in middle of this symbol for plotting\r
 \r
-                   hf_model(hf_n,:) = hf_gain*(spread(sc+M/2) + exp(-j*freq_sample*Nhfdelay)*spread_2ms(sc+M/2));\r
+                   hf_model(hf_n,:) = hf_gain*(spread(sc+M/2) + exp(-j*freq_sample_rads*Nhfdelay)*spread_2ms(sc+M/2));\r
 \r
                    sc += M;\r
                    hf_n++;\r
                 end\r
 \r
+                tx_fdm_sym_log = [tx_fdm_sym_log tx_fdm ];\r
+\r
                 % AWGN noise and phase/freq offset channel simulation\r
                 % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im\r
 \r
@@ -242,7 +245,7 @@ function sim_out = ber_test(sim_in)
             % est HF model power for entire code frame (which could be several symbols)\r
 \r
             if hf_sim\r
-              frame_hf_model = reshape(hf_model(hf_n-Nsymb/Nc:hf_n-1,:),1,(Nsymb/Nc)*length(freq_sample));                       \r
+              frame_hf_model = reshape(hf_model(hf_n-Nsymb/Nc:hf_n-1,:),1,(Nsymb/Nc)*length(freq_sample_hz));                       \r
               sim_out.hf_model_pwr = [sim_out.hf_model_pwr mean(abs(frame_hf_model).^2)];\r
             else \r
               sim_out.hf_model_pwr = [sim_out.hf_model_pwr 1];\r
@@ -250,7 +253,7 @@ function sim_out = ber_test(sim_in)
 \r
             % "genie" SNR estimate \r
             \r
-            snr = (tx_fdm*tx_fdm')/(M*variance);\r
+            snr = (tx_fdm_sym_log*tx_fdm_sym_log')/(M*variance);\r
             sim_out.snr_log = [sim_out.snr_log snr];\r
   \r
             % de-modulate\r
@@ -311,10 +314,8 @@ function sim_out = ber_test(sim_in)
         figure(3);\r
         clf;        \r
         y = 1:Rs*2;\r
-        [rr,cc] = size(hf_model);\r
-        x = 1:cc;\r
         EsNodBSurface = 20*log10(abs(hf_model(y,:))) + EsNodB;\r
-        mesh(x,y,EsNodBSurface);\r
+        mesh(1:length(freq_sample_hz),y,EsNodBSurface);\r
         grid\r
         title('HF Channel Es/No');\r
     end\r
@@ -417,7 +418,7 @@ sim_in.verbose      = 2;
 sim_in.hf_delay_ms  = 2;\r
 sim_in.hf_sim       = 1;\r
 sim_in.Esvec        = 10;\r
-sim_in.Ntrials      = 100;\r
+sim_in.Ntrials      = 400;\r
 \r
 dqpsk_pwr_hf = ber_test(sim_in);\r
 \r