Rayleigh Distributed Wireless Channel in Matlab
In this short blog, I will show how to design a Rayleigh distributed wireless Channel (often known as Rayleigh fading)in Matlab. This blog is for my students’ future reference for the course Introduction to Internet of Things (IOT104TC). But all are welcome to benefit.
Theory on Rayleigh fading
Rayleigh fading ideally represents multi-path fading in wireless transmission as shown in the figure above. It is the most common small-scale or fast-fading effect.
Mathematically, Rayleigh fading is the sum of two uncorrelated Normally distributed Gaussian Random variables. The power of the Rayleigh-faded channel is exponentially distributed. Hence, oftentimes Rayleigh-faded effect is often represented as an exponentially distributed random variable.
The Code
Let X1, and X2 be two normally distributed random variable with mean 0 and variance 1/2. Then X is complex normal variable with mean 0 and variance 1, i.e. X~CN(0,1). [Task to check in Matlab: abs(mean(h)) and abs(var(h)) ]
X = X1 + jX2; %(‘j’ represents the imaginary unit.)
% Z = X1 +jX2;
% Let h~exp(1) is an exponentially distributed channel.h = sqrt(1/2)*(randn(1,nbr_realizations) + ...
1i*randn(1,nbr_realizations));R = abs(h); % Rayleigh distributed
h_2 = R.^2; % Exponential distributedhistogram(h_2)
Var_ = var(h_2)
Mean_ = mean(h_2)histogram(h_2)
Var_ = var(h_2)
Mean_ = mean(h_2)
Exponentially Distributed Channel Gain in Wireless Transmission?
Consider a wireless transmission system in which the transmit transmits with power ‘Pt’ to the receiver at a distance ‘r’. Then, using ‘alpha’ as the distance-related transmission coefficient, and using fast-fading gain ‘h_2’ calculated above, the received power at the receiver is ‘Pr’. It can be coded in Matlab as follows.
Pr = Ps*r^(-alpha)*h_2
Now, following this, it is very straight forward to calculate any signal-to-noise or signal-to-interference-plus-noise ratios, or event the bit-rate of any wireless system.