📄 condor_data_sim_154a.m
字号:
%%function [num_err,ber_sim] = ... condor_data_sim_154a(FS_CONT,... DATA_LENGTH,RSCODE,PACKET_LENGTH, ... TC,BURST_LENGTH,SYMBOL_LENGTH, ... compound_channel, channel_mask, ... snr_dB,s2,B, ... T_INT,N_INT, ... timing_offset, ... rx_pre_overlap)% $$$ %% $$$ % Necessary path% $$$ addpath ../../matlab/util ../../matlab/rng ../../matlab/pulse ...% $$$ ../../matlab/receiver ../../matlab/data_signal ...% $$$ ../../src/channel ../../src/scrambling_timehopping;fprintf('FS_CONT = %2.0e, DATA_LENGTH = %d\n', ... FS_CONT,DATA_LENGTH);fprintf('TC = %2.1e, BURST_LENGTH = %d, SYMBOL_LENGTH = %d\n', ... TC,BURST_LENGTH,SYMBOL_LENGTH);fprintf('Length of the channel mask = %d\n',length(channel_mask));fprintf('snr = %d [dB], B = %2.1e\n',snr_dB,B);fprintf('T_INT = %2.1e, N_INT = %d\n',T_INT,N_INT);fprintf('timing_offset = %2.1e\n',timing_offset);fprintf('Channel Mask = [');fprintf('%d ',channel_mask);fprintf(']\n');if RSCODE == 1 fullblock = floor(DATA_LENGTH/330); PACKET_LENGTH = fullblock*378 + (DATA_LENGTH-fullblock*330) + 48; fprintf('RS coding enabled, ');else PACKET_LENGTH = DATA_LENGTH; fprintf('No RS coding, ');endfprintf('PACKET_LENGTH = %d\n',PACKET_LENGTH);% Variance of the noise% $$$ snr = 10.^(snr_dB/10);% $$$ Eb = 1;% $$$ s2 = Eb ./ (2*snr);t0 = clock;% Pre-construction of the data signal of interestsamples = get_samples_values(TC,FS_CONT, ... BURST_LENGTH, ... SYMBOL_LENGTH, ... PACKET_LENGTH);[ep] = get_ep(PACKET_LENGTH, ... SYMBOL_LENGTH, ... BURST_LENGTH, ... samples);symbol_start = get_symbol_start(PACKET_LENGTH,samples);[burst, burstlength] ... = condor_init_data_signal(FS_CONT, PACKET_LENGTH, ... TC,BURST_LENGTH,SYMBOL_LENGTH, ... ep.ths, ep.scrambling, samples, ... compound_channel);% Get the data bit (coded or uncoded)[tx_bit,data_bit] = get_tx_bit(DATA_LENGTH,RSCODE,ep.interleaver_seed);% Get the data signal of interest[rx_data] ... = get_data_signal(PACKET_LENGTH, ... samples.burst, samples.symbol, burstlength, ... burst,ep.ths,symbol_start,tx_bit);% Add AWGNfprintf('add noise, ');% Parameters for the generation of the Gaussian noiseALPHA = PACKET_LENGTH/2;Ts = TC * SYMBOL_LENGTH;Nt = Ts * FS_CONT;s2 = s2*(2*B)/FS_CONT;[noise_0 noise_1] = randn_bl(ALPHA,Ts,Nt,B,s2);rx_data = rx_data + [noise_0 noise_1];clear noise_0 noise_1;% Add the end of the preamble at the beginning of the packetLch = length(compound_channel);Lrp = length(rx_pre_overlap);rx_data = [zeros(1,Lrp-Lch+1) rx_data];rx_data(1:Lrp) = rx_data(1:Lrp)+rx_pre_overlap;clear rx_pre_overlap;% Add noise at the end of the signalALPHA = 2;Nt = Lrp/2;Ts = Nt / FS_CONT;s2 = s2*(2*B)/FS_CONT;[noise_0 noise_1] = randn_bl(ALPHA,Ts,Nt,B,s2);rx_data = [rx_data noise_0 noise_1];clear noise_0 noise_1;% Related to the channel mask, necessary for the decoderchannel_mask_unit = T_INT*N_INT;% Timing-error stemming from the timing acquisitiontiming_offset_samples = (timing_offset*FS_CONT) + (Lrp-Lch+1);fprintf('timing_offset = %d (samples)\n',timing_offset_samples);% Receiver%fprintf('receive\n');demod_bit = ed_decoder(rx_data, ep.ths, ... symbol_start, ... 0,samples.burst,samples.symbol, ... channel_mask, channel_mask_unit, ... timing_offset_samples, ... PACKET_LENGTH, FS_CONT, T_INT, N_INT);if RSCODE == 1 % RS decoding dec_bit = rs_decoder_154a(demod_bit,ep.interleaver_seed);else dec_bit = demod_bit;end% Compute the BERnum_err = sum(abs(data_bit-dec_bit));ber_sim = num_err/PACKET_LENGTH;dt=etime(clock,t0);fprintf('(dt = %.2f), avg. ber = %.12f\n',dt,mean(ber_sim));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -