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
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
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
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
%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
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