# Modelling a Communication System and Bit Error Rate

Fig1: Communication System |

__Channel__

A channel is the medium between the transmitter and receiver. The signals (for example electromagnetic waves) transmitted from the source face different materials in the medium (air, water, buildings, dust or static charges around) it may increase the signal strength or decrease it by some random factor. This is called fading and this factor is called fading variable.

It can also add some random component to the transmitted signal. We can see this as additive noise. When this component follows a Gaussian distribution we call it additive Gaussian Noise.

__Signal Modelling__

Let us generate a random bit stream which signifies the date need to be sent. We choose the probability of 1 occurring is 0.6. First we generate a random uniform random vector.

u=rand(1000,1)

Now let us turn all the elements bigger than 0.4 to 1 and rest to 0. Note that since the original vector is uniform between 0 and 1, the output vector will have 1 with 0.6 probability.

d=zeros(1000,1);

u(d>0.4)=1;

__Modulation:__

**a) BPSK**

y=zeros(1000,1);

y(d==0)=-1;

y(d==1)=+1;

**B) QPSK or QAM**

dI=d(1:2:999);

dQ=d(2:2:1000);

x=zeros(500,1);x(dI==0 && dQ==0)=sqrt(1/2)*(1+1j);

x(dI==0 && dQ==1)=sqrt(1/2)*(-1+1j);

x(dI==1 && dQ==1)=sqrt(1/2)*(-1-1j);

x(dI==1 && dQ==0)=sqrt(1/2)*(1-1j);

__Channel Modeling__

__1. Additive gaussian Noise__symbol. We choose the noise variance as 0.01 and mean as 0.

m=0;

s=sqrt(.01);

N=size(x);

n=m+s*rand(N);

y=x+n;

__2. Fading__h=sqrt(1/2)(randn(N,1)+1j*randn(N,1));

y=h*x+n;

__Receiver Model__dhat= 1 if y >0

dhat =0 if y<0

dhat=zeros(1000,1);

dhat(y>0)=1;

QPSK:

dIhat=zeros(500,1);

dIhat(imag(y)<0)=1;

dQhat=zeros(500,1);

dQhat(real(y)<0)=1;

dhat=zeros(1000,1);

dhat(1:2:999)=dIhatl

dhat(2:2:1000)=dQhat;

__BER performance__

e=(d!=dhat);

ber=sum(e)/1000;