#### kosamoza

##### Newbie level 4

clc

clear

%BPSK Transmitter

data=randint (1,100000);

data=(2*data)-1;

%AWGN Channel

EbNo_db=0:0.5:10;

No=10.^(0.1*-EbNo_db);

for k=1:length(EbNo_db)

noise =sqrt(No(k)/2).*randn(1,100000);

end

%BPSK Receiver

received = data + noise;

for i=1:length(received)

if(received(i)>=0)

est_bits(i)=1;

else if (received(i)<0)

est_bits=0;

end

end

end

errors = sum (xor(data,est_bits));

Pe(EbNo_db+1)=errors/length(data);

semilogy(EbNo,Pe);