You are on page 1of 13

HIGHER COLLEGES OF TECHNOLOGY

ABUDHABI WOMEN’S COLLEGE

Department of Electrical Engineering Technology

Laboratory report

ELE 4233 Mobile Communication

Lab 07
Simulation of a wireless link in Rayleigh channel in
MATLAB- SIMILINK

Student name: Shouq Mohamed aljahwari


Student ID: H00366552
Date: 31st, October, 2020

0
Þ Objective
• To study and understand Rayleigh channel.

• To study the different Losses can happen in a Radio communication system.

• To understand Matlab Simulation of a wireless link in Rayleigh channel

Þ Equipment & Software Needed

• Matlab Simulation Software

• Matlab Communication Tool box”

Þ Introduction & Theory


o There are a variety of changes that occur in phase and amplitude upon an RF
signal. This regarding a signal that has been transmitted from BS to MU,
otherwise known as the base station and mobile unit. Moreover, a signal of a
carrier frequency is the one in question. Those variety of changes occur due to
various things. It could be the signals scattering caused be interferences or as
simple as the car motion. When a faded signal is received, there become a set
of components that will are distinguishable at the mobile antenna. Firstly, the
direct LOS, or the direct line-of-sight. Secondly, the specular component
along with the diffuse component. Lastly, is the combination of both the direct
and specular components, this is known as the coherent received component.
In the case of the last one, the diffuser will beknown as the noncoherent
received component.

o Furthermore, in the case of having a channel where there are no coherent


received components, meaning there is no direct LOS or specular components,
the channel will be named as
Rician. Shown is an example of
a Rician model:

Figure 1: Rician model


1
o When there are independent reflected waves shown upon the received signal
and distributed equally in phase and amplitude, this is an example of Rayleigh
fading channel. In such examples it is considered that the signal’s magnitude
going through a communication channel will be change and fade according to
Rayleigh distribution. Rayleigh distribution is the radial component of the
total addition of 2 uncorrelated Gaussian random variables.

o In mobile communications 3 types of distributions are the most popular;


Nakagami distributions, Rician distributions, and Rayleigh distributions.
Those distribution types are used for signal with scattering at the receiver.
Usually those signals have reached the receiver along multiple paths. Rayleigh
distribution in specific, is used when total magnitude of the vector is related to
its directional components.

Matlab Simulation of Rayleigh distribution.

Þ Procedures

o Open the Matlab simulation software.

o Write required commands/code in Command Window.

o Execute commands/code.

o Find results and plots in simulation Window.

o Compare and analyze practical output with theoretical output.

2
Þ Simulation Results (Codes & Figures)

Part A- code:

With Matlab buikt in Function


% %MATLAB Script for computing Rayleigh distribution with Matlab function
x = [0:0.01:2];
p = raylpdf(x,0.5);
figure;
plot(x,p)

Part A- Result:

Figure 2: Rayleigh distribution using Matlab function


3
Part B- code:

Using Statistical Way .


% %MATLAB Script for computing Rayleigh distribution using histogram
clear all;
close all;
N= 10^5;
h=1/sqrt(2)* [randn(1,N) + j*randn(1,N)];
k=abs(h);
hist(k,100);

Part B- Result:

Figure 3: Rayleigh distribution using Histogram

4
Part C- code:

MATLAB Script for computing the BER for BPSK modulation

% MATLAB Script for computing the BER for BPSK modulation in a


% Rayleigh fading channel and compred to AWGN Channel
% Clear all the previously used variables
clear all;

format long;
% Frame Length
bit_count = 10000;
%Range of SNR over which to simulate
SNR = 0: 1: 40;
% Start the main calculation loop
for aa = 1: 1: length(SNR)

% Initiate variables
T_Errors = 0;
T_bits = 0;

% Keep going until you get 100 errors


while T_Errors < 100

% Generate some random bits


uncoded_bits = round(rand(1,bit_count));
% BPSK modulator
tx = -2*(uncoded_bits-0.5);

% Noise variance
N0 = 1/10^(SNR(aa)/10);

% Rayleigh channel fading


h = 1/sqrt(2)*[randn(1,length(tx)) + j*randn(1,length(tx))];
% Send over Gaussian Link to the receiver
rx = h.*tx + sqrt(N0/2)*(randn(1,length(tx))+i*randn(1,length(tx)));

%---------------------------------------------------------------
% Equalization to remove fading effects. Ideal Equalization
% Considered
rx = rx./h;

% BPSK demodulator at the Receiver


rx2 = rx < 0;

% Calculate Bit Errors


diff = uncoded_bits - rx2;
T_Errors = T_Errors + sum(abs(diff));
T_bits = T_bits + length(uncoded_bits);

end
% Calculate Bit Error Rate
BER(aa) = T_Errors / T_bits;
disp(sprintf('bit error probability = %f',BER(aa)));
end

%------------------------------------------------------------
% Finally plot the BER Vs. SNR(dB) Curve on logarithmic scale

5
% Calculate BER through Simulation
% Rayleigh Theoretical BER
SNRLin = 10.^(SNR/10);
theoryBer = 0.5.*(1-sqrt(SNRLin./(SNRLin+1)));
% Start Plotting
% Rayleigh Theoretical BER
figure(1);
semilogy(SNR,theoryBer,'-','LineWidth',2);
hold on;
% Simulated BER
figure(1);
semilogy(SNR,BER,'or','LineWidth',2);
hold on;
xlabel('SNR (dB)');
ylabel('BER');
title('SNR Vs BER plot for BPSK Modualtion in Rayleigh Channel');
% Theoretical BER
figure(1);
theoryBerAWGN = 0.5*erfc(sqrt(10.^(SNR/10)));
semilogy(SNR,theoryBerAWGN,'blad-','LineWidth',2);
legend('Rayleigh Theoretical','Rayleigh Simulated', 'AWGN Theoretical');
axis([0 40 10^-5 0.5]);
grid on;

Part B- Result:

Figure 4: signal to noise ratio against bit error rate graph

bit error probability = 0.144400

bit error probability = 0.128000

6
bit error probability = 0.104900

bit error probability = 0.090800

bit error probability = 0.076300

bit error probability = 0.065600

bit error probability = 0.053500

bit error probability = 0.044800

bit error probability = 0.037000

bit error probability = 0.027200

bit error probability = 0.023500

bit error probability = 0.017800

bit error probability = 0.014500

bit error probability = 0.011800

bit error probability = 0.010500

bit error probability = 0.007950

bit error probability = 0.006200

bit error probability = 0.005150

bit error probability = 0.003733

bit error probability = 0.002900

bit error probability = 0.002540

bit error probability = 0.002100

bit error probability = 0.001557

bit error probability = 0.001325

bit error probability = 0.000945

bit error probability = 0.000785

bit error probability = 0.000771

bit error probability = 0.000537

bit error probability = 0.000343

bit error probability = 0.000256

7
bit error probability = 0.000222

bit error probability = 0.000200

bit error probability = 0.000159

bit error probability = 0.000127

bit error probability = 0.000101

bit error probability = 0.000069

bit error probability = 0.000071

bit error probability = 0.000048

bit error probability = 0.000042

bit error probability = 0.000033

bit error probability = 0.000022

8
Þ Observation/Findings
o I have found while applying the code in order to achieve the final required output,
that the in Rayleigh channel, SNR and BER have an inversely proportional
relationship. Meaning that the greater is the bit error ratio, the less is the signal
to noise ratio in dB.

Þ Discussion/Analysis

o I have applied the first code in MATLAB in order to find Rayleigh


distribution. This was achievable using a built-in function in MATLAB, which
was the command p = raylpdf(x,0.5). this built-in function is used to compute
the probability density function of the Rayleigh distribution. Where x is the
support and should be a non-negative value, 0.5 is the parameter of the
Rayleigh distribution, and p is the probability density of the Rayleigh
distribution at each element of x and corresponding parameter. I then applied
the plot command in order to generate the figure that will represent my code.
Figure 2 shows almost like a sine wave shape where the maximum is on point
0.5 on the x axis.

o Secondly, I have also applied a code to find Rayleigh distribution, however,


this time it was not as direct as using a built-in function. This time I applied a
statistical way which was using a histogram. Moreover, the randn
function will generate an array of random numbers and the hist is the
histogram function. The output I got was a figure almost identical to the
previous figure in overall shape wise, however it has a different outline and
measurements. This obviously was a histogram shape with very narrow and
small blocks that will mimic the shape of “almost a sine wave”, where it rose
up to 0.75 and then fell down back, shown in figure 3.

9
o Lastly, I applied a code that will compute the bit error rate for the BPSK
modulation. Also, this code will produce a figure that will discuss BER in the
y axis will SNR in dB in the x axis and show the plot for BPSK modulation
that occur in Rayleigh channel. It shows a comparison between the AWGN
channel and Rayleigh channel in those two parameters. We can analyze that
the AWGN theoretical line shows an incline line. This line describes that
whenever the bit error ratio decrease, the signal to noise ratio increase.
However, for the Rayleigh theoretical, the line shows the same relationship
but much sharper. Meaning that in Rayleigh theoretical when BER decrease,
the SNR will increase much faster and bigger than AWGN. Also, the
simulation of Rayleigh also is appropriate to the theory. Meaning there are no
major differences between the two, shown in figure 4. Furthermore, the result
explaining the bit error probability was displayed respectively to the code.

Þ Calculation

L Matlab Simulation of Rayleigh distribution.

10
Þ Conclusion

o Overall, I accomplished the goals of this lab to study and understand the concept of
the Rayleigh channel and generate a figure of it in the MATLAB software
using two different ways; built-in function and histogram. Also, I was able to
learn about all different type of losses that can occur in a radio communication
system. But more importantly, during that I was able to come to the conclusion that
explained the relationship between the BEK and SNR in Rayleigh channel. I have
learned that this relationship is inversely proportional, meaning the more the BEK,
the smaller SNR. And lastly, I was able to reflect and analyze all of that using the
MATLAB simulation.

Þ References
o https://en.wikipedia.org/wiki/Rayleigh_distribution

11
Grading Rubric

SL No Rubrics Mark Code


1 Individual Assessment 30 (10 +10+10) A
2 Troubleshooting and problem solving/ post lab test 10 B
3 Introduction/ Objective/ Procedure 5 C
4 Calculations /Codes/ Theory. 5 D
5 Data collection/ Findings / observations 5 E
6 Diagrams / Charts / Figures and Plots with Captions 10 F
7 Analysis & Discussion / (theory vs actual) 15 G
8 Conclusions/ Summary /self-reflection 15 H
Quality of work performed including quality of lab report,
9 5 I
neatness etc.

12

You might also like