Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q/ Plot bit error rate (BER) of BPSK modulate data as a function of SNR for three different channels: ? AWGN channel ? Rayleigh fading

Q/ Plot bit error rate (BER) of BPSK modulate data as a function of SNR for three different channels: ? AWGN channel ? Rayleigh fading channel ? Ricean channel Plot BER versus SNR at receiver both theoretical and simulated (6 curves in one plot).

_______________________________________________________________________

This code will help you >> Do some additions and changes on it

clear all; close all; SNR=[0:1:14]'; %a vector to represent SNR (dB) to be considered snr=10.^(SNR/10); %convert SNR in dB to linear %we create initial zero vectors for BER BER_AWGN_simulated=zeros(length(SNR),1); % create vector for bit error rate of AWGN channel simulated BER_AWGN_theoratical=zeros(length(SNR),1); % create vector for bit error rate of AWGN channel theoretical BER_Rayleigh_simulated=zeros(length(SNR),1);; % create vector for bit error rate of Rayleigh channel simulated BER_Rayleigh_theoratical=zeros(length(SNR),1);; % create vector for bit error rate of Rayleigh channel theoretical %BER_Ricean_simulated=zeros(length(SNR),1); % create vector for bit error rate of Ricean channel simulated %BER_Ricean_theoratical=zeros(length(SNR),1); % create vector for bit error rate of Ricean channel Theoretical %We need to run Monte Carlo loop since the data is random and to make %results realiable we can run the same code for multiple iterations and then take avarage of it. %For instance, here we are considering 1000 iterations Maximum_iterations=1000; %maximum number of iterations Ns=100; %Creat data to be transmitted with length Ns symbols f=100; %Frequency of the carrier T=1;%Bit rate per symbol for i=1:length(SNR), %iterations for each SNR for k=1:Maximum_iterations %Number of iterations %%%%%%%%%%%%%%%%%%% %%%%Data Generation %%%%%%%%%%%%%%%%%%% Data=2*round(rand(1,Ns))-1; % The data will be generated either 1 or -1 %%%%%%%%%%%%%%%% %BPSK Modulation %%%%%%%%%%%%%%%% %First generate a sin wave with given t and f % Let varies from t=0.005:(5/Ns):5; t=0.005:(5/(Ns)):5; %Here we generate the modulated signal by multiplying it with %carrier (basis function) BPSK_Modulated=Data.*(sqrt(2/T)*cos(2*pi*f*t)); %%%%%%%%% %Channels %%%%%%%%% %Here we will prepare channels for different SNR values n=(1/sqrt(2))*(randn(length(BPSK_Modulated),1)+j*randn(length(BPSK_Modulated),1)); %AWGN Channel Data_AWGN=sqrt(snr(i))*BPSK_Modulated+n'; % Rayleigh Channel taps=1/sqrt(2)*(randn(length(BPSK_Modulated),1)+j*randn(length(BPSK_Modulated),1)); %these are zero mean unit variance complex Gaussian variables Data_Ray=sqrt(snr(i))*abs(taps').*BPSK_Modulated+n'; %SIGNAL %%%%%%%%%%%%%%%%% %%%%%Demodulation %%%%%%%%%%%%%%%%% %We begin demodulation by multiplying the received signal again with %the carrier (basis function) %Demodulated for AWGN channel Demodulated_AWGN=Data_AWGN.*(sqrt(2/T)*cos(2*pi*f*t)); rcvd_AWGN=real(Demodulated_AWGN); %demodulated signal %because phase is 0, if phase is h, r1=real(Bpsk*exp(-j*2*pi*h)); i.e., phase is cancelled da1=find(rcvd_AWGN>=0);da2=find(rcvd_AWGN<0); rcvd_AWGN(da1)=1;rcvd_AWGN(da2)=-1; %Demodulated for Rayleigh channel Demodulated_Ray=Data_Ray.*(sqrt(2/T)*cos(2*pi*f*t)); rcvd_Ray=real(Demodulated_Ray); dr1=find(rcvd_Ray>=0);dr2=find(rcvd_Ray<0); rcvd_Ray(dr1)=1;rcvd_Ray(dr2)=-1; %%%%%%%%%%%%% %BER analysis %%%%%%%%%%%%% %errors in the current iteration Ber_a=length(find((Data-rcvd_AWGN)~=0)); %number of errors in AWGN Ber_r=length(find((Data-rcvd_Ray)~=0)); %number of errors in Rayleigh BER_AWGN_simulated(i)=BER_AWGN_simulated(i)+Ber_a; %AWGN BER_Rayleigh_simulated(i)=BER_Rayleigh_simulated(i)+Ber_r; %Rayleigh %plot data only once rather than in each iteration. Therefore, we can say plot only %when i=1 and k=1 if i==1 & k==1 plot(Data); title('Data to Transmit'); hold on plot(BPSK_Modulated,'g'); xlabel('Time (seconds)-->'); ylabel('Amplitude (volts)-->'); title('BPSK Modulated signal'); hold on plot(real(Data_AWGN),'r') plot(real(Data_Ray),'b') figure plot(real(Demodulated_AWGN),'r') hold on plot(real(Demodulated_Ray),'b') xlabel('Time (seconds)-->'); ylabel('Amplitude (volts)-->'); title('Demodulated signal'); % figure; % stem(Data) % hold on % stem(received_AWGN) % stem(received_Ray) % title('Impulses of Received bits'); % xlabel('Time (seconds)-->'); % ylabel('Amplitude (volts)') end end %AWGN BER is function of sqrt(2*SNR) BER_AWGN_theoratical(i)=.5*erfc(sqrt(2*snr(i))/sqrt(2)); %Rayleigh BER is different function of SNR BER_Rayleigh_theoratical(i)=.5*(1-sqrt(snr(i)./(1+snr(i)))); BER_AWGN_simulated(i)=BER_AWGN_simulated(i)/Ns/k; BER_Rayleigh_simulated(i)=BER_Rayleigh_simulated(i)/Ns/k; end figure semilogy(SNR,BER_AWGN_theoratical,'-sk','Linewidth',2,'MarkerFaceColor','k') grid on hold on semilogy(SNR,BER_AWGN_simulated,'--sk','Linewidth',2,'MarkerFaceColor','k') semilogy(SNR,BER_Rayleigh_theoratical,'-or','Linewidth',2,'MarkerFaceColor','r') semilogy(SNR,BER_Rayleigh_simulated,'--or','Linewidth',2,'MarkerFaceColor','r') axis([0 SNR(length(SNR)) 1e-4 .5]) xlabel('SNR (dB)') ylabel('BER') legend('AWGN Theory','AWGN Simulated','Rayleigh Theory','Rayleigh Simulated',2)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago

Question

How was your life influenced by those events?

Answered: 1 week ago

Question

Which of these influenced your life most dramatically?

Answered: 1 week ago