www.pudn.com > RS.rar > RS_BPSK_System_Simulation.m


> BER performance of RS &amt; Golay coding and BPSK modulation system.
> AWGN channel is used in this simulation.

E=1; > energy of per symbol
EbN0db_sim=0:6; > signal to noise ratio in dB of simulation
>************************ BER of simulation ************************
for nEN = 1:length(EbN0db_sim)
> Clear bit error counters
berr_counter(nEN)=0; > with Golay coding
berr_counter1(nEN)=0; > without Golay coding
> Clear counter of transmitted symbols.It has 12 bits per symbol.
ndata=0;
> terminate bit errors
berrlim=500;
while berr_counter(nEN)<berrlim
ndata=ndata+1;
source=round(rand(1,12)); > Generate one data source.
> Golay encoder
[encoder_data]=Golay_encoder(source);
> BPSK modulation
mod_data=encoder_data.*2-1;
> Attenuation calculation
spow=sum(mod_data.*mod_data)/24;
attn=0.5*spow*10.^(-EbN0db_sim(nEN)/10);
attn=sqrt(attn);
noise=randn(1,length(mod_data)).*attn; > Add White Gaussian Noise (AWGN)
> Data is transmitted in AWGN channel.
channel_data=mod_data+noise;
> BPSK demodulation
demo_data=channel_data>0;
> Golay decoder
[decoder_data]=Golay_decoder(demo_data);
> Count bit errors with Golay coding
for i=1:12
if (decoder_data(i)~=source(i))
berr_counter(nEN)=berr_counter(nEN)+1;
end
end
ber(nEN)=berr_counter(nEN)/(ndata*24); > bit error rate in simulation with Golay coding
> Count bit errors without Golay coding
mod_data1=source.*2-1; > modulation data without Golay coding
noise1=randn(1,length(mod_data1)).*attn;
channel_data1=mod_data1+noise1; > Data is transmitted in AWGN channel without Golay coding.
demo_data1=channel_data1>0; > demodulation data without Golay coding
for i=1:12
if (demo_data1(i)~=source(i))
berr_counter1(nEN)=berr_counter1(nEN)+1;
end
end
ber1(nEN)=berr_counter1(nEN)/(ndata*12); > bit error rate in simulation without Golay coding
end
end
> theoretical bit error rate of BPSK modulation without Golay coding
EbN0db_the=0:0.1:6; > signal to noise ratio in dB of theory
for i=1:length(EbN0db_the)
SNR=exp(EbN0db_the(i)*log(10)/10);
ber_the(i)=0.5*erfc(sqrt(SNR));
end
[x]=textread('RS7.txt','>f'); > with RS(7,3,5)
[y]=textread('RS127.txt','>f'); > with RS(127,122,7)

semilogy(EbN0db_sim,ber,'o'); > BER-EbNo curve with Golay coding
hold
semilogy(EbN0db_sim,ber1,'*'); > BER-EbNo curve without Golay coding
semilogy(EbN0db_the,ber_the); > theoretical BER-EbNo curve
semilogy(EbN0db_sim,x,'ro'); > BER-EbNo curve with RS(7,3,5) coding
semilogy(EbN0db_sim,y,'r*'); > BER-EbNo curve with RS(127,122,7) coding

title('\bf BER performance of Golay &amt; RS coding and BPSK modulation system');
xlabel('\fontsize{10} \bf Eb/N0');ylabel('\fontsize{10} \bf BER');
legend('BER-EbNo with Golay coding','BER-EbNo without coding','theoretical BER-EbNo curve','BER-EbNo with RS(7,3,5)','BER-EbNo with RS(127,122,7)');