Professional Documents
Culture Documents
MATLAB CODE
clc;
clear all;
close all;
%Nb is the number of bits to be transmitted
T=1;%Bit rate is assumed to be 1 bit/s;
%bits to be transmitted
b=[1 0 1 0 1]
%Rb is the bit rate in bits/second
NRZ_out=[];
RZ_out=[];
Manchester_out=[];
t=0.005:0.005:5;
%Frequency of the carrier
f=5;
%Here we generate the modulated signal by multiplying it with
%carrier (basis function)
Modulated=NRZ_out.*(sqrt(2/T)*cos(2*pi*f*t));
figure(3);
plot(Modulated);
xlabel('Time (seconds)-->');
ylabel('Amplitude (volts)-->');
title('BPSK Modulated signal');
y=[];
num_bit=10101; %Signal length
max_run=20; %Maximum number of iterations for a single
SNR
Eb=1; %Bit energy
SNRdB=0:1:9; %Signal to Noise Ratio (in dB)
SNR=10.^(SNRdB/10);
hand=waitbar(0,'Please Wait....');
for count=1:length(SNR) %Beginning of loop for different SNR
avgError=0;
No=Eb/SNR(count); %Calculate noise power from SNR