Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MATLAB-based Homework for Weeks 4 and 5

TELE9753, Term 1, 2023, v2

This is individual homework.   Each student should hand in a two- to three-page report with the corresponding MATLAB scripts attached. The scripts for each part should have enough comments and a brief description. Note that although you use the script of Part 1 in other parts, you need to provide a separate script for each part.

You need t start with Part 1 and build the skeleton of your simulator.  Then, in Parts 2 and 3, you will change the transmitter and receiver sides.

To do this homework, you may create an account with MathWorks using your the UNSW email address and then use Online MATLAB in the following address: https://matlab.mathworks.com/

1 Project Details

In this project, you are asked to implement a Rayleigh fading channel and evaluate the error performance of space-time block code  (Alamouti scheme) with two transmit antennas and a receiver antenna and compare them with receiver diversity under maximal ratio combing (MRC).

2 Part 1: Rayleigh Fading Channel

Simulate a wireless communication system over a flat Rayleigh fading channel with a single transmit antenna and a single receiver antenna. Assume BPSK signals (+1 or -1) are transmitted. The bit error rate (BER) of the system needs to be obtained through the simulation.  Then the BER curve of the systems should be plotted against the SNR of range 0 to 30 dB with 5 dB steps.  Then, compare your simulation results to the theoretical results of the system. Comment and justify your simulation results. (10 Marks)

Hints for simulation:

1. You need to generate a uniformly distributed random binary sequence for the message blocks of arbitrary size, e.g.  100 bits.

blck_size =  100;

traals =  1000;

blck=randi([0  1],  1, blck_size); % Random block

2.  To have an average bit error rate, many trials are needed. You can use 1000 or a larger number of trials. Each trial means transmitting one block of 100 bits.

3.  BPSK  signaling/modulation  is  used  in  the  simulation,  i.e.,  the  mapping  scheme  is  {1, 0}  → {−1, +1}. Hence, you need to convert 0s and 1s to -1s and 1s.

blck_tx =  1−2 . *blck; % BPSK modulation

4. You need to have two nested loops:  an outer loop for the SNR range in set {0, 5, 10, 15, ··· , 30} and the inner loop for the trials where you transmit block 1 to block 1000.

5.  All channels are Rayleigh fading and independent of each other.

6.  To compute the variance of the noise, σn(2), you need to convert the SNR from dB (snr_db) to absolute value (snr). We normalize the energy per symbol to 1, i.e., Es  = 1. Then, σn(2)  = N0 /2 = 1/(2 · SNR).

snr =  10^(snr_db/10); noise_var =  1/(2 *snr);

% Es /N0

% Noise variance

7.  All receivers are subject to additive white Gaussian noise (AWGN). Hence, you need to add zero- mean complex normal distribution CN(0,σn(2)). The noise variance for the real part is equal to that of the imaginary part.

w_real = normrnd(0,sqrt(noise_var),[1 blck_size]);

w_imag = normrnd(0,sqrt(noise_var),[1 blck_size]);

w = w_real +  1i * w_imag;

As normrnd function requires statistics and machine learning Toolbox, you can use randn function instead and multiply it with the standard deviation of the noise, σn . That is,

w_real = sqrt(noise_var) *randn(1,blck_size);

w_imag = sqrt(noise_var) *randn(1,blck_size);

w = w_real +  1i * w_imag;

8.  All symbols experience fading, hence you need to consider path loss.

h_real = sqrt(0 .5) *randn(1,blck_size);

h_imag = sqrt(0 .5) *randn(1,blck_size);

h = h_real +  1i * h_imag;

blck_rx = h . * blck_tx + w; % received sequence

9. You need to detect the received symbols by considering the real part.  Here, we assume that you know the path coefficient h, i.e., coherent detection. Please see page 54 of David Tse’s book for the detection. You can use either y or y before detection (y is blck_tx) to cancel the fading effect. This operation is called equalization which is not the subject of this course.  The path coefficient h is estimated using pilots and interpolation in frequency domain which is not the subject of this course.

blck_rx_eq = blck_rx . /h;

10.  Please make sure you always use element-wise division, multiplication, etc.  Use ML ML detector by considering the decision boundary 0 for BPSK to decide whether 1 or -1 was transmitted and map them to 0 or 1, and get the detected block, blck_rx_detected.

blck_rx_detected = real(blck_rx_eq)  < 0;

11.  At the receiver, you can assume you know the transmitted blocks and compare the received block with the transmitted one to count the bit errors. The summation of all the bit errors over the total number of bits gives you the bit error probability or bit error rate (BER) for each SNR point.

error = xor(blck_rx_detected, blck);

error_count = error_count + sum(error);

Pb = error_count/(blck_size *trials);

12.  Plot the simulation results as bit error rate (BER) or Pb  in a semi-logarithmic scale versus the signal-to-noise ratio (SNR) in dB using semilogy() function.  See page 54 of David Tse’s book for the theoretical BER. Note that the equation is based on the absolute value of SNR, not SNR in dB.

3 Part 2: Maximal Ratio Combining (MRC)

Simulate a system with a single transmit and two receive antennas (L=2).  Assume that the maximal ratio combing  (MRC) scheme MRC is employed at the receiver.  You are asked to find the bit error probability of this scheme and compare it with the result of Part  1 as well as the theoretical error probability.  Additionally, increase the number of receive antennas to L = 4 and compare with L = 2 and L = 1 (no receive diversity). You need to plot the results and discuss them.  (10 Marks)

Hints for simulation:

1.  To get independent paths, you need to generate path coefficient, hi , as many as the number of receive antennas you have, i.e., L.

h_real = sqrt(0 .5) *randn(L, blck_size);

h_imag = sqrt(0 .5) *randn(L, blck_size);

h = h_real +  1i * h_imag;

2.  Note that ri ejθi    is the polar form of a complex number, here, a path coefficient.  Since we have hi  = ri ejθi , therefore, αi  = ri e jθi    = hi(∗) .  The conjugate of a complex number in MATLAB is obtained by conj() function.

3. You need to be careful about the coherent detection.   For equalization as discussed in Part  1, assuming you have L rows of h and blck _rx vectors, i.e., a matrix of size L × blck _size for L independent paths corresponding to L receive antennas. You may use the following script:

blck_rx_eq = sum(conj(h) . *blck_rx,1) . /sum(h . *conj(h),1);

4. You may need more trials for this part to get a smooth curve, in particular at high SNR points.

4 Part 3: Space-time Block Coding

Space-time block code (STBC) is an extension of block codes to the scenario with two or more transmit antennas.  The simplest form of STBCs with two transmit antennas (also referred to as the Alamouti scheme) was proposed with error performance investigated by simulation.  You are asked to evaluate the bit error performance of the scheme through computer simulation. You do need to obtain the error performance for one receive antenna for the Alamouti scheme ( 2Tx, 1Rx ). Plot the results versus SNR and discuss your observation and the expectation.  (10 Marks)

Our aim in this homework is to challenge you with an implementation task.  Further hints will be added to this document upon your request (so please check this document on Moodle from time to time. The current version is v1, written on the first page).  If you think some details are missing, you may request for clarification.  You can make the assumption needed provided that you mention in in your report.