\r
ldpc;\r
\r
- rate = 1/2; \r
+ rate = 3/4; \r
mod_order = 4; \r
modulation = 'QPSK';\r
mapping = 'gray';\r
tx_phase = rx_phase = 0;\r
tx_data_buffer = zeros(1,2*framesize);\r
s_data_buffer = zeros(1,2*Nsymb);\r
+ C_log = [];\r
\r
for nn = 1: Ntrials\r
\r
- %tx_bits = round( rand( 1, framesize*rate ) );\r
- tx_bits = [1 0 zeros(1,framesize*rate-2)];\r
+ tx_bits = round( rand( 1, framesize*rate ) );\r
+ %tx_bits = [1 0 zeros(1,framesize*rate-2)];\r
\r
% modulate\r
\r
%if ((sc+M) > length(spread)) || ((sc+M) > length(spread_2ms))\r
% sc =1 ;\r
%end\r
+ comb = conj(spread(sc:sc+M-1))' + conj(spread_2ms(sc:sc+M-1))';\r
if hf_phase_only\r
- comb = conj(spread(sc:sc+M-1))' + conj(spread_2ms(sc:sc+M-1))';\r
tx_filt = tx_filt.*exp(j*angle(comb));\r
hf_angle_log = [hf_angle_log angle(comb)];\r
else\r
if hf_phase_only == 0 % C already 1 if we are just tweaking phase\r
tx_filt *= hf_gain;\r
end\r
+ C_log = [C_log abs(comb)*hf_gain];\r
end\r
tx_filt_log = [tx_filt_log tx_filt];\r
\r
if nn == 1\r
tx_bits_tmp = tx_bits(skip:length(tx_bits));\r
rx_bits_tmp = rx_bits(skip:length(rx_bits));\r
- end\r
+ else\r
+ tx_bits_tmp = tx_bits;\r
+ rx_bits_tmp = rx_bits;\r
+ end\r
\r
error_positions = xor( rx_bits_tmp, tx_bits_tmp );\r
Nerrs = sum(error_positions);\r
tx_data_buffer(framesize+1:2*framesize) = tx_bits;\r
s_data_buffer(Nsymb+1:2*Nsymb) = s_ch;\r
\r
- st_tx = (Nfiltsym-1)*bps+1;\r
- st_s = (Nfiltsym-1);\r
+ offset = Nfiltsym-1;\r
+ if (phase_est)\r
+ offset += floor(Nps/2);\r
+ end\r
+ st_tx = offset*bps+1;\r
+ st_s = offset;\r
\r
detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, ...\r
s_data_buffer(st_s+1:st_s+Nsymb), min(100,EsNo));\r
printf("EsNo (dB): %f Terrs: %d BER %f BER theory %f", Es, Terrs,\r
Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2)));\r
if ldpc_code\r
- printf(" LDPC: Terrs: %d BER: %f", Terrsldpc, Terrsldpc/Tbitsldpc);\r
+ printf(" LDPC: Terrs: %d BER: %f Ferrs: %d FER: %f", \r
+ Terrsldpc, Terrsldpc/Tbitsldpc, Ferrsldpc, Ferrsldpc/(Ntrials-1));\r
end\r
printf("\n");\r
end\r
end\r
\r
Ebvec = Esvec - 10*log10(bps);\r
- sim_out.BERvec = BERvec;\r
- sim_out.Ebvec = Ebvec;\r
- sim_out.TERvec = TERvec;\r
+ sim_out.BERvec = BERvec;\r
+ sim_out.Ebvec = Ebvec;\r
+ sim_out.TERvec = TERvec;\r
if ldpc_code\r
sim_out.BERldpcvec = BERldpcvec;\r
sim_out.TERldpcvec = TERldpcvec;\r
scat = rx_symb_log(2*Nfiltsym:length(rx_symb_log)) .* exp(j*pi/4);\r
plot(real(scat), imag(scat),'+');\r
\r
- if hf_sim\r
- figure(3);\r
-\r
- if hf_phase_only\r
- plot(hf_angle_log);\r
- axis([1 10000 min(hf_angle_log) max(hf_angle_log)])\r
- else\r
- plot(abs(spread));\r
- hold on;\r
- plot(abs(spread_2ms),'g');\r
- hold off;\r
- axis([1 10000 0 1.4])\r
- end\r
- end\r
+ figure(3);\r
+ clf;\r
+\r
+ if hf_phase_only\r
+ plot(hf_angle_log);\r
+ axis([1 10000 min(hf_angle_log) max(hf_angle_log)])\r
+ else\r
+ plot(C_log);\r
+ end\r
end\r
endfunction\r
\r
% Start simulations ---------------------------------------\r
\r
more off;\r
-sim_in.verbose = 1;\r
+sim_in.verbose = 2;\r
\r
-sim_in.Esvec = 1:5; \r
-sim_in.Ntrials = 3;\r
-sim_in.framesize = 576;\r
+sim_in.Esvec = 5; \r
+sim_in.Ntrials = 100;\r
+sim_in.framesize = 100;\r
sim_in.Rs = 400;\r
sim_in.phase_offset = 0;\r
sim_in.phase_est = 0;\r
sim_in.w_offset = 0;\r
-sim_in.plot_scatter = 0;\r
+sim_in.plot_scatter = 1;\r
sim_in.hf_delay_ms = 2;\r
-sim_in.hf_sim = 0;\r
+sim_in.hf_sim = 1;\r
sim_in.Np = 6;\r
sim_in.Ns = 5;\r
sim_in.hf_phase_only = 0;\r
-sim_in.hf_mag_only = 0;\r
-sim_in.ldpc_code = 1;\r
+sim_in.hf_mag_only = 1;\r
+sim_in.ldpc_code = 0;\r
\r
Ebvec = sim_in.Esvec - 10*log10(2);\r
BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10)));\r