Hi again,
I come out with this code for BER calculation of the AWGN communication system:
(*THIS CODE IS FOR BER (Bit Error Rate) SIMULATION OF THE AWGN \
COMMUNICATION SYSTEM*)
Clear["`*"] ; (*Clear All previous saved variables and symbols*)
bits = 10^6; (*total number of bits*)
sym = bits/2; (*total number of symbols*)
tx = ((2*RandomInteger[1, sym]) -
1) + (I* ((2*RandomInteger[1, sym]) -
1)); (*Transmitted signal*)
For[i = 1, i < 2, i++, snrdB = i; (*value of SNR in dB*)
snr = 10^(0.1*snrdB);(*changing SNR to linear*)
sd = 1/Sqrt[snr/2]; (*calculation of noise vaiance*)
noise = 1/Sqrt[
2]*(RandomReal[NormalDistribution[], {sym, 1}] +
I*RandomReal[
NormalDistribution[], {sym, 1}]); (*AWGN noise generation*)
y = tx + (sd*noise); (*Received Signal after adding the noise*)
rx = Sign[
Re[y]] + (I*
Sign[Im[y]]); (*Hard dicision demodulation of the Received \
Signal*)
error = Count[tx rx, -1]; (*calculating number of errors*)
ber = error/bits; (*calculating bit errors rate*)
Print[ber]; (*printing bit errors rate*)
]
the problem is that there must be error, but there is no error !!!!
I just started with simple one loop for SNR = 1 dB, in this case (low SNR) there must be error. However, for high SNR (e.g 20 dB the probability of error is very low, but still there is probability of error.
there is mistake, but I can't point it.
Hope people who have experience help me for fixing this.
Note:
SNR is the signal to noise ratio we take the range from 0 dB to 20 dB, and we measure the BER (Bit Error Rate), then we plot the relation between them.
bits; is the total number of bits, for the purpose of accuracy generally we choose 10^6, but here for simplicity I choose 10^2.
Kind regadrs
Jamal