How to simulate BER, capacity and outage probability of NOMA (Rayleigh fading) using MATLAB?


Simulation of BER of Non orthogonal multiple access (NOMA) in Rayleigh fading channel - MATLAB code with explanation



In the previous post, we saw how to simulate a simple two user NOMA network over an AWGN channel in MATLAB. We also plotted the BER vs SNR graphs of both the users and observed the waterfall trend. The AWGN assumption simplified the channel model and allowed us to learn the basic skeletal operation of NOMA. In this post, we will use MATLAB to simulate the capacity, outage and BER performance of a two user NOMA network by following a more realistic model namely, Rayleigh fading model. The MATLAB code to plot BER, capacity and outage probability of NOMA are also available for download in this page. So, let's get started!

Wireless channel is prone to multipath propagation and fading. Several channel models are available to capture the effects of fading. Each model deals with a particular scenario. One such model is Rayleigh fading model. Rayleigh fading model can be used when there is no line of sight (LOS) path between the transmitter and the receiver. In other words, all multipath components have undergone small scale fading effects like reflection, scattering, diffraction, shadowing etc.

We are going to consider an extreme case of Rayleigh fading where each transmitted bit undergoes a different attenuation and phase shift due to multipath transmission. In other words, the channel changes for every bit. We will first look at the system model and signal model of NOMA and then the MATLAB code for simulating it. We will simulate the bit error rate (BER), capacity and outage of NOMA. The MATLAB code for NOMA can be downloaded here.

Capacity and Outage probability for NOMA - MATLAB code
BER of NOMA - MATLAB code

See this post: How to do power allocation in NOMA?

System model

We are considering downlink transmission from base station (BS) to the two users (Can we have more than 2 NOMA users?). Our network will look like this.

User 1 is the far/weak as he is far away from the transmitting BS. User 2 is the near/strong user. Let $d_1$ and $d_2$ denote their distances from the BS.

Signal model

The BS has two distinct messages $x_1$ to user 1 (far user), and $x_2$ to user 2 (near user). $\alpha_1$ and $\alpha_2$ are the power allocation factors for the far and the near user respectively ($\alpha_1$ + $\alpha_2$ = 1). In NOMA, to promote user fairness, more power is given to the far user and less power to the near user. That is, $\alpha_1$ > $\alpha_2$. Throughout this post, we will use $\alpha_1$=0.75 and $\alpha_2$=0.25. This is an arbitrary choice.  Let $h_1$ and $h_2$ denote the channel from the BS to the far and the near user respectively. 

See this post to find how performance of NOMA varies with different choices of $\alpha_1$ and $\alpha_2$. To see how to optimize $\alpha_1$ and $\alpha_2$, see this post: How to do power allocation in NOMA?

NOMA encoding and transmission

As we know already, the superposition coded NOMA signal transmitted by the BS is, $$x = \sqrt{P}(\sqrt{\alpha_1}x_1 + \sqrt{\alpha_2}x_2)$$ where, $P$ is the transmit power. The copy of $x$ received at the far user after propagating through channel $h_1$ is, $$y_1 = h_1x + w_1$$ Similarly, the copy of $x$ received at the near user after propagating through channel $h_2$ is, $$y_2 = h_2x + w_2$$

NOMA decoding at User 1 (far user)

Expanding the received signal at user 1, \begin{align} y_1 &= h_1x + w_1\\ &= h_1\sqrt{P}(\sqrt{\alpha_1}x_1 + \sqrt{\alpha_2}x_2) + w_1 \\ &= \underbrace{h_1\sqrt{P}\sqrt{\alpha_1}x_1}_\textrm{desired & dominating} + \underbrace{h_1\sqrt{P}\sqrt{\alpha_2}x_2}_\textrm{interference & low power} + \underbrace{w_1}_\textrm{noise} \end{align} Since $\alpha_1$ > $\alpha_2$, direct decoding of $y_1$ would yield $x_1$. The term containing the $x_2$ component will be treated as an interference. The signal to interference and noise ratio for the far user is, $$\gamma_1 = \dfrac{|h_1|^2P\alpha_1}{|h_1|^2P\alpha_2+\sigma^2}$$ and his achievable data rate is, $$R_1 = log_2(1 + \gamma_1) = log_2(1+\dfrac{|h_1|^2P\alpha_1}{|h_1|^2P\alpha_2+\sigma^2})$$

NOMA decoding at User 2 (near user)

Expanding the received signal at user 2, \begin{align} y_2 &= h_2x + w_2\\ &= h_2\sqrt{P}(\sqrt{\alpha_1}x_1 + \sqrt{\alpha_2}x_2) + w_2\\ &= \underbrace{h_2\sqrt{P}\sqrt{\alpha_1}x_1}_\textrm{interference & dominating} + \underbrace{h_2\sqrt{P}\sqrt{\alpha_2}x_2}_\textrm{desired & low power} + \underbrace{w_2}_\textrm{noise} \end{align} User 2 must first perform successive interference cancellation (SIC) before decoding his own signal. SIC is carried out as follows:

  1. $y_2$ is directly decoded to obtain $x_1$ or rather, an estimate of $x_1$, that is $\tilde{x}_1$.
  2. $y_2' = y_2 - \sqrt\alpha_1 \tilde{x}_1$ is computed.
  3. $y_2'$ is decoded to obtain an estimate of $x_2$.

We are making a perfect SIC assumption here. What happens if SIC is imperfect?
The signal to interference and noise ratio at the user 2 for decoding the user 1 signal (before SIC) is, $$\gamma_{1,2} = \dfrac{|h_2|^2P\alpha_1}{|h_2|^2P\alpha_2+\sigma^2}$$ The corresponding achievable data rate is, $$R_{1,2} = log_2(1 + \gamma_{1,2}) = log_2(1+\dfrac{|h_2|^2P\alpha_1}{|h_2|^2P\alpha_2+\sigma^2})$$ After after cancellation of user 1's signal using SIC, the signal to noise ratio at the user 2 for decoding its own signal is, $$\gamma_2 = \dfrac{|h_2|^2P\alpha_2}{\sigma^2}$$ The corresponding achievable data rate is, $$R_2 = log_2(1 + \gamma_2) = log_2(1+\dfrac{|h_2|^2P\alpha_2}{\sigma^2})$$

Here, we have considered only two NOMA users. We can also multiplex more than two users in the same frequency carrier to accommodate more users in our network.

Simulation using MATLAB

Now that we have seen the mathematical details of NOMA we can go ahead and write a MATLAB code to simulate it. We will write two codes. One to study the BER performance and another one to study the capacity and outage performance of NOMA. So, let's get started.

Capacity and outage probability of NOMA - MATLAB simulation

You can download the MATLAB code to plot capacity and outage probability of NOMA here. Capacity and Outage probability for NOMA - MATLAB code
  1. First, let's declare the values of some parameters. Let's say the distances are, $d_1 = 1000$ meters and $d_2 = 500$ meters. Let's set the power allocation factors as $\alpha_1 = 0.75$ and $\alpha_2 = 0.25$. You can set any values for these parameters but make sure that the far user is given the higher fraction of power.
  2. We want a plot of capacity and outage probability as a function of transmit power. So, let's initialize a range of transmit power from 0 dBm to 40 dBm
  3. Let's set our system bandwidth as $B = 1MHz$. Let's calculate the thermal noise power as $No = kTB$, where $k = 1.38\times 10^{-23} J/K$,$T=300K$.
  4. Next, we have to generate the Rayleigh fading coefficients $h_1$ and $h_2$ to simulate the channel between the two users. This can be done using the following MATLAB command $h_i = \sqrt{d_i^{-\eta}}(randn(1,N)+1i*randn(1,N))/\sqrt{2}$. Here, $\eta$ is called the path loss exponent.Typically we set $\eta=4$
  5. To plot capacity, we need to calculate $R_1 = log_2(1+\dfrac{|h_1|^2P\alpha_1}{|h_1|^2P\alpha_2+\sigma^2})$, $R_{1,2} =log_2(1+\dfrac{|h_2|^2P\alpha_1}{|h_2|^2P\alpha_2+\sigma^2})$, and $R_2 = log_2(1+\dfrac{|h_2|^2P\alpha_2}{\sigma^2})$.
  6. Find the average value of each of the above quantities for every transmit power
  7. Calculating the above quantities for different power levels (for eg., from 0 to 40 dBm), we get a plot as shown below:

  8. Next, we will plot the outage probabilities. Set target rate for each user. For example, for user 1, we set the target rate as 1 bps/Hz and for user 2, we set the target rate as 2 bps/Hz.
  9. Count the number of times the values calculated in step 5 fall below the target rates and take the average. In other words, set a counter for user 1, which is incremented every time $R_1 \lt 1 bps/Hz$ and another counter for user 2 which increments every time $R_{1,2} \lt 1 bps/Hz$ or $R_2 \lt 2 bps/Hz$
  10. Plot the outage probabilities as a function of transmit power and the graph would look like this:

BER of NOMA - MATLAB simulation

You can download the MATLAB code to plot BER of NOMA here. BER of NOMA - MATLAB code
  1. Follow steps 1 to 4 of capacity and outage simulation explained above
  2. Let's next generate noise samples for both users. The formula is, $w_i = \sqrt{noise power}(randn(1,N) + 1i*randn(1,N))/\sqrt{2}$
  3. Generate random binary data for both users
  4. Modulate the data using any digital modulation scheme. In the code given here, BPSK is used for both users.
  5. Calculate the superposition coded signal $x$
  6. Calculate $y_1$ and $y_2$
  7. Equalize $y_1$ and $y_2$ by diving by $h_1$ and $h_2$ respectively
  8. From the equalized version of $y_1$ perform direct BPSK demodulation to get $\tilde{x_1}$.
  9. Compare $\tilde{x_1}$ with user 1's original data and estimate BER using the biterr function
  10. Directly decode the equalized version of $y_2$ to estimate $x_1$
  11. Remodulate $x_1$ and subtract the remodulated $x_1$ component after multiplying it with $\sqrt{\alpha_1}$ from the equalized version of $y_2$. Decode this signal to get $\tilde{x_2}$.
  12. Compare $\tilde{x_2}$ with user 2's original data and estimate BER using the biterr function.
  13. Plot the BERs as a function of transmit power and the graph would look like this:

Note

Make sure you use the linear value of power in all calculation and not the dBm value. (Especially while calculating $R_1$, $R_{1,2}$, $R_{2}$.

Next post: How to do power allocation in NOMA?

References:

  1. Theoretical BER: F. Kara, H. Kaya, BER Performances of Downlink and Uplink NOMA in the Presence of SIC Errors over Fading Channels. IET Communications. Vol. 12, no. 15, pp. 1834-1844.
  2. Y. Saito, Y. Kishiyama, A. Benjebbour, T. Nakamura, A. Li, and K. Higuchi, Non-Orthogonal Multiple Access (NOMA) for Cellular Future Radio Access, IEEE 77th Vehicular Technology Conference (VTC Spring) (Dresden, Germany), 2013, pp. 1–5.
  3. A. Benjebbour, Y. Saito, Y. Kishiyama, A. Li, T. Harada, and T. Nakamura, Concept and Practical Considerations of NonOrthogonal Multiple Access (NOMA) for Future Radio Access, International Symposium on Intelligent Signal Processing andbCommunication Systems (ICPACS 2013) (Okinawa, Japan), 2013, pp. 770– 774.
If you have any doubts or if you find any mistakes, you can comment below. I'll try my best to help you. Thank you!

Comments

  1. Shouldn't we plot it with respect to the thing called Eb/No or something ? I am not sure why most BER curve plot with that kind of thing ?

    ReplyDelete
    Replies
    1. Yes. We can plot them as a function of Eb/No or as a function of SNR also.

      Delete
    2. Oh in that case then how can we determine the mean and the variance of the noise to achieve the desirable Eb/N0 ?

      Delete
    3. There is this relation between SNR and Eb/No. For a given Eb/No, the SNR would be,
      SNR = (Eb/No)*bit rate/BW
      where the bit rate (in bps) and bandwidth (in Hz) depends on the modulation scheme.

      To achieve the desirable Eb/No, we can use this expression to obtain the variance of AWGN as P/SNR, where P is the measured signal power and SNR depends on Eb/No.

      Again, the mean would be zero.

      Delete
    4. Hi Joe,

      I am still having some difficulties plotting the BER vs Eb/No plot. How do i get Eb/No from the transmit power given in the code and plot it?

      Thanks

      Delete
    5. Hi Joel, from the transmit power and noise power, you can find the transmit SNR. Once the SNR is known, Eb/No can be calculated as SNR*Bandwidth/bitrate

      Delete
    6. Hi, i want to ask in the 2 user noma system, what's the bit rate if using bpsk? For the common bpsk, there should be only one bit/symbol but in norma there more than one signal transmitted together, will it change?

      Delete
    7. Hi, Do you have the matlab code for the comparison of capacity of FDMA and noma?

      Delete
    8. Hi, i am conffused about why the noise power is -174+10*log10(BW) what is the number -174?

      Delete
    9. Hi, thermal noise power = kTB, where k is boltzmann constant, T is temperature (300K).
      10log(kT/10^-3) = -174 dBm

      Delete
    10. Hi ,
      Still , I am confused of finding SNR from transmit power in Rayleigh fading ?

      Delete
    11. Hi Sakthik, just fix the noise power to be some value (for eg., -174 dBm) and
      calculate SNR = Pt - No, where Pt is the transmit power in dBm

      Delete
    12. I think SNR= Pt/No
      Please correct me

      Delete
    13. Hi San, in linear scale snr = Pt/no. In dB scale, it is SNR = Pt - No.

      Delete
  2. How did you get the theoretical BER ? What is the closed form expression ?

    ReplyDelete
    Replies
    1. Hi! Closed form expression for BER was derived by following the steps given in this paper as reference:

      Kara, Ferdi & Kaya, Hakan. (2018). BER Performances of Downlink and Uplink NOMA in the Presence of SIC Errors over Fading Channels. IET Communications. 12. 1834-1844. 10.1049/iet-com.2018.5278.

      You can refer this work for details

      Delete
  3. Can you explain why user 1 has less achievable capacity rate than user 2?Like why the graph behaves like this?

    ReplyDelete
    Replies
    1. User 1 has limited achievable capacity because of the interference from user 2. User 2 does not have this problem because interference is removed by SIC. If we see the expressions for their achievable rates, R1 has an additional interference term at the denominator, while R2 does not have this term.

      Delete
  4. Can you provide the code for simulation of OFDM ber vs snr ?

    ReplyDelete
    Replies
    1. Hi! I have the code for ofdm. Ping me electronicswithme@gmail.com and i will send it to you.

      Delete
  5. HELLO can you please help me i am trying to create the same code but in QPSK not BPSK and with Rayleigh distribution

    ReplyDelete
  6. i need help to write the same code with QPSK modulation + AWGN (0 main and unit variance) + Rayleigh distribution with 0 main and (SEGMA^2 ) variance but (BER vs SNR). i have little problems please help me .

    ReplyDelete
    Replies
    1. Hi Rania! You can use the same code given in this post. Just change the modulation and demodulation parts.

      If your problem still persists, can I know where exactly you get the error?

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. Hi Trishna,

      I read through your code and made some changes in the demodulation part.
      You can download the modified code from this link

      https://drive.google.com/file/d/1YFnkQJeQkyB5xSJn5W8GmLzcPb4WcLeC/view?usp=sharing

      hope this helps

      Delete
    2. Thanks a lot. I understood the concept so well and also to model it. Can't thank you enough for your generosity. Thanks Thanks Thanks! Many Thanks!

      Delete
  8. Can you please tell how to simulate for rician channel. Ive been trying to find a matlab code to make it work and unfortunately I am unable to do so. Please help

    ReplyDelete
    Replies
    1. Hi Ankita, Rician channel is very similar to Rayleigh fading channel, except for the presence of LOS path

      Usually we model Rayleigh fading coefficients as h = x + i*y, where, x and y are zero mean, gaussian random variables.

      In the case of Ricean fading also, we model h as, h = x + i*y. But now, x is non-zero mean gaussian random variable while y has zero mean. Both x and y have the same variance.

      The Ricean parameter (K) can be used to calculate the mean of x and the variance of both x and y.

      Here is a sample code for NOMA in a ricean fading channel

      https://drive.google.com/file/d/1YFnkQJeQkyB5xSJn5W8GmLzcPb4WcLeC/view?usp=sharing

      Hope this helps

      Delete
  9. @Joe what does this equation for Rayleigh fading indicate???
    zs1=complex(randn(2,1),randn(2,1))/sqrt(2);

    what is 2, 1 here???

    ReplyDelete
    Replies
    1. Hi Satarupa,

      randn(2,1) generates zero mean, unit variance gaussian random variables in the form of a 2 x 1 vector.

      complex(randn(2,1),randn(2,1)) would give the rayleigh fading coefficients (2x1 vector) in the form of x + iy, where x and y are independent gaussian random variables with zero mean unit variance.

      Since the variance of randn(2,1) is 1, complex(randn(2,1),randn(2,1)) will have variance 2. So we divide by sqrt(2) to make the overall variance to be 1.

      Hope this helps

      Delete
  10. Hi Joe,
    Can you explain to me why BPSK modulation has this formula?
    x1 = 2*data1 - 1;
    x2 = 2*data2 - 1;
    What about QPSK modulation?
    And

    x1_hat(eq1>0) = 1;
    x12_hat(eq2<0) = -1;
    x2_hat(real(y2_dash)>0) = 1;
    what does this all mean?
    Please help me!

    ReplyDelete
    Replies
    1. Hi, in the formula
      x = 2*data - 1,
      If you sustitute data = 0, you will get x = -1, and if data = 1, you will get x = 1. Thus we have mapped bit 0s to -1s and bit 1s to +1s, which is BPSK modulation

      QPSK is just BPSK done both in I and Q channels.

      x1_hat(eq1>0)=1
      This command assigns a value of 1 to x1_hat whenever eq1 (the received symbol to be demodulated) is greater than 0. Otherwise, x1_hat will be set to 0. This line performs BPSK demodulation, i.e., symbol to bit mapping

      Delete
    2. Thank you for your help!

      Delete
    3. x12_hat(eq2<0) = -1;
      shouldn't it be x12_hat(eq2<0) = 0;

      y2_dash = eq2 - sqrt(a1*pt(u))*x12_hat; what is the use of this command?

      Delete
  11. Can you give me permission to use your matlab code in my report? do you mind about that?

    ReplyDelete
  12. hi....can you please check the code for last figure of theoretical and simulation BER. In the code theoretical BER calculation part is not there

    ReplyDelete
    Replies
    1. Hi, thanks for notifying. Updated it!

      Delete

  13. I'm sorry I might have to ask a very stupid question. What's the difference between the path loss exponent used here to calculate the channel factor and the path loss (dB) calculate by Free Space loss? What's the unit of path loss exponent here?

    ReplyDelete
    Replies
    1. We know that the path loss is proportional to (distance)^(path loss exponent).
      The path loss exponent is just a number in the range 2 to 6.
      It gives the rate at which the signal power decays with distance.
      In free space model, the path loss exponent = 2.
      To model more dense urban environments, we have chosen the exponent to be 4.

      Delete
  14. Hi!
    Why when calculating the signal to noise ratio, the channel gain is squared?
    and

    I really don't understand what this formula means
    R_1=〖log〗_2 (1+γ_1 )=〖log〗_2 (1+(|h_1 |^2 Pα_1)/(|h_1 |^2 Pα_2+σ^2 ))
    Please helps!

    ReplyDelete
    Replies
    1. The definition of SNR is signal power/noise power. The rayleigh fading coefficient, h is in the voltage amplitude domain.

      But in SNR equation, we have to represent it in terms of its power. We know that power = voltage^2/R. Assuming R = 1 ohm, power of the rayleigh fading coefficient is |h|^2

      The formula for R1 is a standard formula for achievable rate of a wireless channel. In general, for any wireless channel with snr = gamma, the achievable rate is given by log_2(1+gamma). This is Shannon's capacity equation.

      Delete
  15. Hi Joe,
    Why do we have to calculate the average value of R1,R12,R2 ?
    and
    p1 = zeros(1,length(Pt)); Tại sao bạn sử dụng hàm số không?
    Can you explain what 'pout' here means?
    pout1=p1/N
    Thank you!

    ReplyDelete
    Replies
    1. Hi, since the wireless channel is very dynamic, the instantaneous capacities will fluctuate so much. Averaging them would give us more useful insights about the overall channel behavior.

      Pout is the outage probability. p1 counts the number of times the achievable rate falls below the target rate, out of N transmissions.

      Delete
  16. Hi joe
    Thank you for this effort

    May I know what we are modeling from line 68 to line 87?

    Another question is can I get some notes about the resulting BER scheme?

    ReplyDelete
    Replies
    1. Hi, we are calculating the theoretical BER in those lines.
      For more details on theoretical BER derivation, please refer this paper:

      Kara, Ferdi & Kaya, Hakan. (2018). BER Performances of Downlink and Uplink NOMA in the Presence of SIC Errors over Fading Channels. IET Communications. 12. 1834-1844. 10.1049/iet-com.2018.5278.

      Delete
    2. OK
      Thank you
      What about modeling the Matlab program from line 68 to line 87?

      Delete
    3. gam_a = 2*((sqrt(a1*pt(u))-sqrt(a2*pt(u)))^2)*mean(g1)/no;
      gam_b = 2*((sqrt(a1*pt(u))+sqrt(a2*pt(u)))^2)*mean(g1)/no;
      ber_th1(u) = 0.25*(2 - sqrt(gam_a/(2+gam_a)) - sqrt(gam_b/(2+gam_b)));

      gam_c = 2*a2*pt(u)*mean(g2)/no;
      gam_d = 2*((sqrt(a2) + sqrt(a1))^2)*pt(u)*mean(g2)/no;
      gam_e = 2*((sqrt(a2) + 2*sqrt(a1))^2)*pt(u)*mean(g2)/no;
      gam_f = 2*((-sqrt(a2) + sqrt(a1))^2)*pt(u)*mean(g2)/no;
      gam_g = 2*((-sqrt(a2) + 2*sqrt(a1))^2)*pt(u)*mean(g2)/no;

      gc = (1 - sqrt(gam_c/(2+gam_c)));
      gd = (1-sqrt(gam_d/(2+gam_d)));
      ge = (1-sqrt(gam_e/(2+gam_e)));
      gf = (1-sqrt(gam_f/(2+gam_f)));
      gg = (1-sqrt(gam_g/(2+gam_g)));

      ber_th2(u) = 0.5*gc - 0.25*gd + 0.25*(ge+gf-gg);

      gamma1(u) = a1*pt(u)*mean(g1)/(a2*pt(u)*mean(g1) + no);
      gamma2(u) = a2*pt(u)*mean(g2)/no;

      These lines of code for programming what?

      Delete
    4. Lines 68 to 87 are modelling the closed form expression of theoretical BER

      Delete
    5. Hi Joe,

      Can you please explain why OP of user 1 is less than user 2? Is it because of power allocation?

      Delete
    6. Hi Trishna,
      It's because of the interference. User 1 performs direct decoding by treating the user 2 data as interference. (as can be observed in the denominator of R1 expression)

      User 2 does not experience any interference since it is removed by SIC

      Delete
    7. Hi Joe,

      How did you go about to calculate the theoretical BER? could you just provide a quick over view of line 68 to 87.

      Thanks

      Delete
    8. Hi Joel,

      The procedure for derivation of closed form expression is explained in this paper:

      Kara, Ferdi & Kaya, Hakan. (2018). BER Performances of Downlink and Uplink NOMA in the Presence of SIC Errors over Fading Channels. IET Communications. 12. 1834-1844. 10.1049/iet-com.2018.5278.

      Delete
  17. Hi Joe,
    Why do you set the target rate for user 1 to 1bps/hz and user 2 to 2bps/hz ?

    ReplyDelete
    Replies
    1. Hi, it is up to us to set the target rates. We set them according to the user's QoS requirements. Usually we set a higher target rate to the near user because he has the better channel

      Delete
    2. Hi,
      Let me ask what does R12 mean here? Why must it?
      Thank you!

      Delete
    3. Hi, user 2 must first decode x1, then perform SIC, then decode his own x2.

      R12 is the achievable rate at user 2 to decode x1.

      R12 is also an important parameter because, if R12 is less than user 1's target rate, it is possible that user 2 decodes x1 erroneously. This would lead to SIC error propagation, leading to errors in decoding of user 2's own signal

      Delete
    4. Hello!
      In the calculation formula R1, R2, the value of the variance is not added, but instead we calculate the thermal noise power in the matlab code? Please explain more about this!
      Thank you!

      Delete
    5. Hi, in R1 and R2, the sigma^2 represents the noise variance. Noise power (kTB) is equal to its variance.

      Delete
    6. Hi joe,
      Let me ask why is the bit error rate and outage probability of the remote user always higher than the near user despite being allocated more power?
      Thank you!

      Delete
    7. Hi, although the remote user is allocated more power, he still suffers interference due to near user transmission. As a result, he has high BER and outage.

      Delete
  18. Hello! How can I convert the channel gain h into dB?

    ReplyDelete
    Replies
    1. Hi, 10log(channel gain) will give the value in dB

      Delete
  19. Hi Joe, in your code you have used noise level as -174. Can we change this value or it should be fixed?

    ReplyDelete
    Replies
    1. Hi, -174 dBm is the fixed value of thermal noise power in 1 Hz bandwidth, when the temperature is 300K.

      10log(kT/10^-3) = -174 dBm, where k is boltzmann constant and T is the temperature.

      Delete
    2. hello Joe, i would like to have your help. i am working on cooperative NOMA for 2 users with direct link, do you have MATLAB code for it.

      Delete
  20. Hi, I need sample code on NOMA D2D please
    thanks

    ReplyDelete
    Replies
    1. Hi, we will see about that in a future post!

      Delete
  21. hi Joe
    If we want to implement the raised cosine transmitter and receiver filters on both sides then how are we going to equalize the Y1 And Y2.
    Sorry for this very dumb question!!!!!

    ReplyDelete
  22. hello JOE can you answer me please ?
    NOMA exist from 2013 why we just use it for the 5G only why we didn't use it before ?
    what i am trying to say is why NOMA is only used for 5G only ?

    ReplyDelete
    Replies
    1. Hi Rania, unlike the old times, these days, the computaional processing capacity of hardware can support NOMA signal processing. This is one of the main reasons for the push towards NOMA now.

      Delete
    2. This comment has been removed by the author.

      Delete
  23. Dear Researchers,
    I found this block is very effective and helpful.
    I need sample code for OFDM based NOMA.
    Thanks in advance.

    ReplyDelete
    Replies
    1. Hi Nayan, glad to know you found the posts useful. More articles about OFDM based NOMA will be posted soon! Thank you

      Delete
  24. Hello Joe
    I found your blog on NOMA too useful, simple with good quality and clarity. I need code of cooperative SWIPT NOMA, please forward it.
    regards

    ReplyDelete
  25. Hello Joe ... I need the MATLAB codes to simulate the massive MIMO-NOMA ... Help me please. Thank you

    ReplyDelete
    Replies
    1. Hi, right now I don't have the code for MIMO-NOMA. But we will see about MIMO-NOMA in future posts..

      Delete
  26. Hi,do you have code about adding imperfect channel state information into NOMA system ?

    ReplyDelete
    Replies
    1. Hi Thomas, ping me electronicswithme@gmail.com and I will send it to you

      Delete
  27. Hey joe, i have some some code for NOMA in which i have only transmitter side, no modulation ... actually i want some BER vs SINR graphs for my work.
    Will you please update my code as i am beginner in NOMA and trying to understand things but i am stuck in it.
    i sent code on electronicswithme@gmail.com please have a look on it .

    ReplyDelete
    Replies
    1. OK, I will take a look at it and let you know

      Delete
  28. why we use equation of bpsk is 2*k-1 ??

    ReplyDelete
    Replies
    1. Hi, BPSK maps bits 0 & 1 as +- 1.
      The expression s = 2*k-1 also does the same thing. It maps bit k=0 to symbol s = -1 and bit k=1 to symbol s = +1.

      However, this is not the only way to do this. We can also use if---else conditional statement to perform this mapping.

      Delete
  29. Hello sir,
    Your posts are very helpful.
    How to plot BER vs SNR? Can u provide the code for that?

    ReplyDelete
    Replies
    1. Hi surya,
      BER vs SNR codes for AWGN channel are available in this post:
      https://ecewireless.blogspot.com/2020/04/simulation-of-ber-of-non-orthogonal.html
      Hope this helps

      Delete
  30. In this post do you have considered BPSK modulation at both users?

    ReplyDelete
    Replies
    1. Hi Umer, yes, BPSK is used for both users here. But it is also possible to go for different modulation schemes to the users

      Delete
  31. Hi Dr joe
    Can you please give me refrences used for understand OP?
    thank you for your time
    best regrades

    ReplyDelete
    Replies
    1. Hi, please go through the papers given in the reference section.
      Hope this helps

      Delete
  32. Hi Joe ,Could you please send MATLAB Code for NOMA with imperfect CSI.
    sreenu.sunkaraboina@gmail.com

    ReplyDelete
    Replies
    1. Hi Sunkaraboina, yet to write the code. Will send it soon!

      Delete
  33. Can you explain how probability of error is calculated from the constellation of the first reference paper?

    ReplyDelete
    Replies
    1. Hi Umer, the first reference paper is a very good foundational work on NOMA theory & understanding it would widen our NOMA toolbox. It would be great to make a post on the theoretical derivation of NOMA BER. We'll cover that in a future post

      Delete
  34. why result of near is the best ( in the NOMA big power go to the far user then far user must get best result )
    i don't understand

    ReplyDelete
    Replies
    1. Hi Abdelrahim, the results depend on several parameters like distance, target rates etc., in addition to power allocation. One explanation for this behavior would be: although the far user is allocated higher power, he suffers from interference due to the near user's data. The near user does not have this interference problem because he performs SIC. Hence, the near user has better performance than the far user. Hope this helps.

      Delete
    2. thanks alooooot bro

      but i need to know , The far user decode only his signal but the near user use SIC so he is decode the signal of the far user and his signal so the error probability is big

      That is what i know always near user have small power and must do 2 decode so have big BER and bad spectral efficiency and every thing is bad ^_^ is that right ? or what i must understand
      thanks bro for reply quickly you are is the best

      Delete
    3. Hi Abdelrahim, the near user has a good channel with the Base station, while the far user does not. So, the near user can decode the far user's signal accurately and also do SIC.

      Delete
  35. Dear Dr. Joe,
    Please guide how to perform equalization in uplink NOMA. Kindly upload code for UL NOMA.

    ReplyDelete
    Replies
    1. Hi, thanks for the suggestion. Will make a post about uplink NOMA soon

      Delete
    2. I am looking for a code to compare OMA NOMA outage probability and BER

      Delete
  36. Can anyone post the matlab code for outage probablity of MIMO-NOMA and OMA??

    ReplyDelete
    Replies
    1. Hi, outage of MIMO-NOMA and OMA is covered in this post
      https://ecewireless.blogspot.com/2020/11/mimo-noma.html
      Hope this helps!

      Delete
    2. dear joe, can you provide the codes on ergodic secrecy rate of multicell MIMO-NOMA?

      Delete
    3. have help in coding part of outage probability of MIMO-NOMA?

      Delete
  37. Hi there Joe :) I really love all the work that you have put in. Could you kindly check your email regarding the inquiry of OFDM - NOMA codes?

    Thank youu so much!
    Regards

    ReplyDelete
    Replies
    1. Hi Joe, thank you for this useful post. Please I want the code of OFDM-NOMA

      Thank you very much

      Delete
  38. Hi,Dr
    i check references for OP but i don't found it if you can share with me the article you used to make condition in matlab code i will be thankful

    ReplyDelete
    Replies
    1. Hi, you can follow the steps given in reference 1 to derive expressions for this system

      Delete
  39. Hello Everyone,
    could anyone provide some information on "Outage Probablity" and how it performs ?

    ReplyDelete
    Replies
    1. Hi, the received signal must be strong enough to be sensed and reliably decoded by the receiver. When it is not strong enough, we say that the receiver is in outage. We find the outage probability by counting the number of times the received power (or rate) falls below a predefined threshold.
      Hope this helps

      Delete
    2. Hi Joe, please could you give us a simple code about to to find the outage probability in religh fading channel when the SINR < SINR_ threshold please please

      Delete
  40. hi joe; can you tell me, how can I superpose the signals of two users, the first one is encoded by QPSK, and the second one BPSK because mod1 and mod2 have not the same dimension.

    ReplyDelete
    Replies
    1. Hi, if you generate N bits for the BPSK user, then generate 2N bits for the QPSK user. After performing the respective modulations, both users will have N symbols. Next you can perform superposition coding of symbols as before. (Because QPSK offers twice the rate as BPSK)
      Hope this helps

      Delete
    2. thank you very match Joe;
      can I set N/2 for BPSK and N for QPSK.
      can you verify to me this code
      problem BER of user1 is very high
      clc; clear variables; close all;

      N = 10^5; %Number of simulations
      SNR = 0:30; %SNR range in dB
      snr = db2pow(SNR); %SNR range in linear scale
      Modulator1=comm.QPSKModulator('BitInput',true);
      Demodulator1=comm.QPSKDemodulator('BitOutput',true);
      Modulator2=comm.BPSKModulator('PhaseOffset',0);
      Demodulator2=comm.BPSKDemodulator('PhaseOffset',0);
      %Generate random data bits for transmission
      s1 = randi([0 1],N,1); %Data bits of user 1
      s2 = randi([0 1],N/2,1); %Data bits of user 2
      % QPSK modulation of data
      xmod1 = step(Modulator1,s1);
      xmod2 = step(Modulator2,s2);
      % Set power factor for users
      a1=[0.2 0.3] ;a2= 1-a1 ;
      % superposition coding
      x = sqrt(a1).*xmod1 + sqrt(a2).*xmod2;
      % Add AWGN to x (Transmit x through an AWGN channel)
      for u = 1:length(snr)
      y1 = awgn(x,SNR(u),'measured'); %Received signal at user 1 corrupted by AWGN
      y2 = awgn(x,SNR(u),'measured'); %Received signal at user 2 corrupted by AWGN

      %AT USER 2
      %Direct decoding of x from y2
      x2_hat1=step(Demodulator2,y2(:,1)); %just a buffer
      x2_hat2=step(Demodulator2,y2(:,2)); %just a buffer
      %AT USER 1
      %Direct decoding of x from y1
      x12_est1 = step(Demodulator1,y1(:,1)); %just a buffer
      x12_est2 = step(Demodulator1,y1(:,2));
      x12_remod1 = step(Modulator1, x12_est1);
      x12_remod2 = step(Modulator1, x12_est2);
      %Subtract remodulated x12_est component from y1
      rem1 = y1(:,1) - sqrt(a2(1,1)).*x12_remod1;
      rem2 = y1(:,2) - sqrt(a2(1,2)).*x12_remod2;
      %Decode x1 from rem
      x1_hat1 = step (Demodulator1,rem1);
      x1_hat2 = step (Demodulator1,rem2);
      %Estimate BER
      ber1(u) = biterr(s1,x1_hat1)/N;
      ber2(u) = biterr(s2,x2_hat1)/(N/2);
      ber3(u) = biterr(s1,x1_hat2)/N;
      ber4(u) = biterr(s2,x2_hat2)/(N/2);
      end

      %plot BER curves
      f1=figure(1);
      semilogy(SNR, ber1,'k-*',SNR, ber2,'b-s',SNR, ber3,'r--^',SNR, ber4,'g--^' ,'linewidth', 1.5);
      legend('User 1 \alpha_1 = 0.2','User 2 \alpha_2 = 0.8','User 1 \alpha_1 = 0.3','User 2 \alpha_2 = 0.7','Location','northwest');
      axis([0 30 10^-4 1]);
      xlabel('SNR (dB)');
      ylabel('BER');
      grid on;
      title('BER for NOMA three users in AWGN channel');

      Delete
    3. Is this the code for BER vs SNR

      Delete
  41. I want to simulate BER NOMA under nyusim channel we can consider Path loss of nyusim channel as h channel gain in Rayleigh fading channel

    ReplyDelete
    Replies
    1. Hi abdelbasset, I am not familiar with NYUSIM. So I've no idea about it.
      I request any our blog followers working on NYUSIM to hop in and respond to this thread.

      Delete
  42. hi joe,can u some new algoirthms for power allocation and user scheduling in NOMA?

    ReplyDelete
    Replies
    1. Hi, we'll see more about power allocation and user pairing strategies in future posts

      Delete
  43. hi joe , how can I simulate NOMA under NYUSIM CHANNEL?
    we can consider nyusim channel gain as path loss of the channel .

    ReplyDelete
    Replies
    1. Hi abdelbasset, I am not familiar with NYUSIM. So I've no idea about it.
      I request any our blog followers working on NYUSIM to hop in and respond to this thread.

      Delete
  44. In term of outage probability, will the outage probability for each OMA user ALWAYS better than the outage probability of each NOMA user right ?
    Particularly
    Outage Probability of Near User OMA < Outage Probability of Near User NOMA
    Outage Probability of Far User OMA < Outage Probability of Far User NOMA
    I have that feeling but do not know how to confirm that, it seem that NOMA user experience some sort of intra resource block interference

    ReplyDelete
    Replies
    1. Hi Minh, if we look at the rate equations of OMA and NOMA,
      R_oma = (1/N)*log2(1+snr)
      R_noma = log2(1+sinr)
      Due to the presence of the (1/N) factor, OMA users experience reduced achievable rate, and hence more outage.
      Especially, the near NOMA user always experiences less outage than near OMA user.
      But this may not always be true for the far users (because they suffer from interference, as you mentioned). For the far user, other factors like power allocation, channel conditions must also be considered.

      Delete
  45. Hi joe , how can i create MATLAB code, when two users are allocated two different distances from BS?

    ReplyDelete
    Replies
    1. Hi, You can just modify the distances in the code provided in this post itself

      Delete
  46. Hey
    I have tried to implement BER vs SNR with the help of your code for fair power allocation system. I am facing some errors in the same. I have mailed my queries to you. Could you please check them?

    ReplyDelete
    Replies
    1. Hi Parva, I made some corrections in your code. It is working now.
      Mailed it to you.

      Delete
  47. How do we extend the SIC for more than 2 users?

    ReplyDelete
    Replies
    1. Hi, SIC for more than two users is explained in this post:
      https://ecewireless.blogspot.com/2020/06/ber-of-3-user-non-orthogonal-multiple.html

      Delete
  48. For BER vs SNR curve, I am taking SNR=received power/ Noise power. But now the performance of users got reversed, far user is performing better than near user. Is it correct? Can I send my file to you for checking it ?

    ReplyDelete
    Replies
    1. OK, i'll take a look at it

      Delete
    2. Can you please send me your email id?

      Delete
    3. electronicswithme@gmail.com

      Delete
    4. Can you send the code matlab for me too plz

      Abdelrahimjomaa2@gmail.com

      Delete
    5. send me the code pleaseeeeeeeee

      Delete
  49. Hi Joe. I am thinking about the effect of channel equalizer on BER. I checked the paper [1] (BER theoretical), it seems that the model of [1] did not consider equalizer and the result was based on demodulating the raw received signal (un-equalized). However, it seems the equalizer is essential. If possible, could you please advise some insights on this question? Best.

    ReplyDelete
  50. Hi joe,

    from where you have taken free space path loss calculations? any reference? pls provide

    ReplyDelete
  51. Hello Everyone...
    Can anyone Please send me the Matlab codes of OUTAGE PROBABLITY of MIMO-NOMA or NOMA in Rician or AWGN fading channels??

    ReplyDelete
  52. Dear Joe,

    Thanks for your quality posts about NOMA. Can you create blogs about NOMA (5G) interference with IRS (6G)? I am extremely looking forward to your new blogs on this subject.

    Best regards

    ReplyDelete
  53. Hi Joe, great post! Learned a lot. Could you please inform me how do I calculate the Theoretical Outage Probabilities for the far and near users , and then plot with the Analytical Outage Probabilities? The final graph would be on X axis: Transmit Power (in dBm) and on the Yaxis, Theoretical and Analytical Outage Probabilities.

    You have shown this for the BER vs Transmit Power (in dBm). Could you please also do the same for Outage Probabilities vs Transmit Power (in dBm)?

    Thanks a lot for your help!

    ReplyDelete
  54. Hello, you have source code matlab for this general? I need it, you can sent to me by mail: thienthanhaovai@gmail.com
    thank you!

    ReplyDelete
  55. Hello Joe
    For decoding x1 from y2 you have mentioned the given code:
    -------------------------------------------------------------------------------------------
    %AT USER 2-------------------------
    %Direct decoding of x1 from y2
    1. x12_hat = ones(1,N);
    2. x12_hat(eq2<0) = -1;

    3. y2_dash = eq2 - sqrt(a1*pt(u))*x12_hat;
    4. x2_hat = zeros(1,N);
    5. x2_hat(real(y2_dash)>0) = 1;
    ---------------------------------------------------
    why have you used line 2: x12_hat(eq2<0) = -1; shouldn't it be x12_hat(eq2<0) = 0

    Also explain the use of : y2_dash = eq2 - sqrt(a1*pt(u))*x12_hat;

    ReplyDelete
    Replies
    1. Hi Huma,

      y2_dash = eq2 - sqrt(a1*pt(u))*x12_hat;
      This command performs the successive interference cancellation. Please see this post for more details:
      https://ecewireless.blogspot.com/2020/04/noma-graphical-example-of-successive.html
      I hope that post will answer why x12_hat(eq2<0) = -1 was used directly instead of x12_hat(eq2<0) = 0

      Delete
  56. Dear Joe,

    Thanks for your quality posts about NOMA, do you have any matlab code for NOMA with physical layer security.

    best regards,

    ReplyDelete
    Replies
    1. Hi , Have you got the code for physical layer security? Can you pls help me with it? Thanks .

      Best Regards,

      Delete
    2. Hey Hi, have you got the code for NOMA with Physical layer security? pls share with me. poovarasivakumar@gmail.com

      Delete
  57. May you please provide the code of Noma for three users using QAM Modulation with AWGN Channel not by Rayleigh fading channel. Secondly how can we map the same code(QAM & QPSK for Three Users using AWGN ) on VLC

    ReplyDelete
  58. Dear Joe , its a very informative post for NOMA BER analysis in down link scenario, can you post the code for up link scenario

    ReplyDelete
  59. Hello Everyone can anyone upload mix Modulation Scheme with BPSK QPSK AND 16 QAM NOMA Matlab Code.

    ReplyDelete
  60. Hii Joe, thank you so much for NOMA matlab codes and for your explanation.
    plz upload NOMA based Spatial Modulation Matlab code..
    thank you!

    ReplyDelete
    Replies
    1. plz , do you have NOMA based Matlab code? you be very helpful if you shared it with me (m_bairakdar@yahoo.com)

      Delete
  61. HiJoe thank you for NOMA Matlab codes can you explain hybrid beaformning with some codes

    ReplyDelete
  62. Hi Joe thank you for NOMA Matlab codes can you explain hybrid beaformning with some codes

    ReplyDelete
  63. Hi Dr joe, Thankyou for this informative blog, do you have the codes for physical layer security with NOMA ? Thanks in advance .

    Regards.

    ReplyDelete
  64. can u please tell the conclusion for above matlab project

    ReplyDelete
  65. Thank you Joe for explain hybrid beamforming with some codes


    ReplyDelete
  66. Dear Joe, please kindly reach out to me at chekwas@engineer.com I have some research works to discuss with you. Thank you.

    ReplyDelete
  67. Hello Joe, I want to ask a questions. If the user 1 is far from BS and the type of user is D2D pair, how to calculate the SINR? It's that still using h1 with d1 is distance from BS to user 1 or how?

    ReplyDelete
  68. Very great and helpful post..
    You really deserve appreciation..
    I have a question:
    (R12(k) < rate1)||(R2(k) < rate2)
    For checking outage of user 2, why do we need count also R12?
    In other words, in case R2 > rate2 but R12 < rate1, why do you consider this case as an outage for user 2??

    ReplyDelete
  69. Hi joe if alpha1= 0.9 and alpha2=0.1 where I am supposed to modify code of ABER at what expressions can you please highlight the line numbers?

    ReplyDelete
  70. Merci Dr. Joe Comment parler de la securité au niveau du recepteur SIC ? Car lors du decodage, l'utilisateur 2 peut avoir les informations sur le message de l'utilisateur 1

    ReplyDelete
  71. Hi Joe, thank you for the valuable information. Can you please help me with the similar code for RSMA

    ReplyDelete
  72. Thanks Dr. Joe How about security at the SIC receiver level? Because during the decoding, user 2 can have the information about the message of user 1

    ReplyDelete
  73. Hello Joe! You 've done a greate job in this blog. Please answer me to that, in order to use this model in THz band communications, is it enough to change the bandwith to BW=10^12 and decrease the distance between the users and the BSs (ex. d1=100, d2=50), or should i do more than that? Thank you in advance!

    ReplyDelete
  74. hello,help me please ; i want the MATLAB code to plot capacity, outage probability And ber of NOMA as a function of SNR .

    ReplyDelete
  75. This comment has been removed by the author.

    ReplyDelete
  76. Hi sir, can you help me to modify our code (MIMO-NOMA) by using any of the channel coding Turbo or polar

    ReplyDelete
  77. Hi sir can you help me to optimize the channel using a specific kind of channel coding

    ReplyDelete
  78. Hello I need Matlab code to plot graph of Outage Probability vs SNR in Raleigh fading channel

    ReplyDelete

Post a Comment

Popular posts from this blog

How to simulate a simple NOMA system (AWGN) using MATLAB?

How to do power allocation in NOMA? (with fairness to far/weak user)