MATLAB Answers

simith
1

I am struggling with a code.the code for signal transmition in Non Orthogonal Multiple Access. Please help me.

Asked by simith
on 15 Mar 2017
Latest activity Commented on by Kardes ASLAN on 7 Aug 2019
clc;
clear all;
n=100;%n0.0f bits for transmit signal
ds1=2;%distance from BS to su1
dp=3;%distance from BS to pu
ds2=4;%distance from BS to su2
%%%the signal from the BS
xp=rand(1,n)>0.5;
xs1=rand(1,n)>0.2;
xs2=rand(1,n)>0.3;
X=xp+xs1+xs2;
%%%the signal received @the su1
for s=0.1:0.01:1%noise variation
N=s*randn(1,n);
ys1=xs1/ds1.^2+N+xp/dp.^2+xs2/ds2.^2
end

  2 Comments

sir simith how you have write this receiver side equation i.e
ys1 = xs1/ds1.^2+N+xp/dp.^2+xs2/ds2.^2
how will you decode and apply SIC on receiver side? plz answer

Sign in to comment.

5 Answers

Answer by Axel Moor on 1 Nov 2017
 Accepted Answer

I hope the code below could be of some help. Regards to you all.
clc;
clear all;
%=============================================================================
%=============================================================================
% Non Orthogonal Multiple Access (NOMA) Simulation
% Version 1: Encode only: Transmitter side, no modulation
%=============================================================================
% This code was based on codes made by Simith (SMT) and Thanh Nguyen (TNY)
% published in:
% Website: MathWorks (R) - www.mathworks.com
% Forum: MATLAB Answers [TM] - /matlabcentral/answers/
% Title: I am struggling with a code.the code for signal transmition in
% Non Orthogonal Multiple Access. Please help me.
% Asked: simith on 15 Mar 2017 - SMT
% Answer: Thanh Nguyen on 21 Apr 2017 - TNY
%=============================================================================
%=============================================================================
%=============================================================================
% Variable Names:
% Variable names were changed according to a notation 'similar' to the
% 'Hungarian Notation' and structured programming for better
% understanding of NOMA techniques since many MATLAB Users are not use
% to the meaning of equation variables related to NOMA mathematics.
%
% +--------- new NOMA variable name
% |
% +---+---+
% VarName_XXX
% +-+-+
% |
% +--- original SMT/TNY variable name,
% '_00' if the variable isn't in SMT/TNY codes
%=============================================================================
% n0.0f bits for transmit signal: 4 bits only - REMOVE '/25' for 100 bits
% as original SMT/TNY codes;
TxBits_n = 100/25;
% distance from Base Station (BS) to Primary User, to User1, to User2 - SMT
% Assuming maximum distance as 10, for attenuation calculation purposes
DstBStoPUser_dp = 3;
DstBStoUser1_ds1 = 2;
DstBStoUser2_ds2 = 4;
MaxDsttoUser_00 = 10;
SumSquareDst_00=DstBStoPUser_dp^2+DstBStoUser1_ds1^2+DstBStoUser2_ds2^2;
% signal from BS - Power allocation already applied on signal(???) - SMT:
% xp=rand(1,n)>0.5;
% xs1=rand(1,n)>0.2;
% xs2=rand(1,n)>0.3;
%
% power allocation for Primary User, User1 and User 2 - TNY:
% pp=0.5;
% p1=0.3; inverse from SMT: p1<->p2
% p2=0.2; inverse from SMT: p1<->p2
%
% NOMA corrected: farther away from Base Station (BS), more allocated power;
% Assuming the Base Station (BS) has total power of 1 and will allocate
% power for each User as proportional to squared distance: Pwr ~ Dst^2
%
TotPwrBS_00 = 1.0;
% previously suggested: 0.3
PwrPUser_pp = TotPwrBS_00*(DstBStoPUser_dp^2)/SumSquareDst_00;
% previously suggested: 0.2
PwrUser1_p1 = TotPwrBS_00*(DstBStoUser1_ds1^2)/SumSquareDst_00;
% previously suggested: 0.5
PwrUser2_p2 = TotPwrBS_00*(DstBStoUser2_ds2^2)/SumSquareDst_00;
%=============================================================================
%%%Create random binary messages/signals from Base Station (BS)
%=============================================================================
% signal of 'n' bits from BS to Primary User, User1 and User2 based on
% with power allocation already applied??? - SMT:
% xp=rand(1,n)>0.5;
% xs1=rand(1,n)>0.2;
% xs2=rand(1,n)>0.3;
% signal stream of Primary User, User1 and User2 - TNY:
% 'rand' generates any number between [0 and 1], NOT binary, noise included???
% xp=rand(1,n);
% xs1=rand(1,n);
% xs2=rand(1,n);
%
% Correct (actual) binary messages of 'TxBits_n' bits length:
% equal probability of 0 and 1 in every bit;
% 'rand' generates numbers in [0 to 1], uniformally distributed;
% Mean is 0.5
%
SgnPUser_xp = rand(1,TxBits_n) > 0.5;
SgnUser1_xs1 = rand(1,TxBits_n) > 0.5;
SgnUser2_xs2 = rand(1,TxBits_n) > 0.5;
%=============================================================================
%%%Superposition Encoding
%=============================================================================
% Direct sum of signals: incorrect - SMT: X=xp+xs1+xs2;
% NOMA: Power-domain Multiplexing, sum of products signal*sqrt(power) - TNY:
%
Enc_X = sqrt(PwrPUser_pp)*SgnPUser_xp;
Enc_X = sqrt(PwrUser1_p1)*SgnUser1_xs1 + Enc_X;
Enc_X = sqrt(PwrUser2_p2)*SgnUser2_xs2 + Enc_X;
%=============================================================================
%%%Received signals for all Users
%=============================================================================
% Adding Gaussian Noise: use 'randn' instead of 'rand':
% 'randn' generates numbers in [-Inf,+Inf], normally distributed (Gaussian);
% Mean is zero, but with strong concetration in [-1 to +1];
% 'rand' generates numbers in [0 to 1], uniformally distributed;
% Mean is 0.5
%
% NOMA: Additive White Gaussian Noise (AWGN) with ZERO MEAN and double-side
% power spectral density, N0/2.
% Noise variation on time N(t) (addition): different for every bit;
%
% Since 'randn' concetrates in [-1 to +1] or even larger and a bit is only
% [0 or 1], and Power<=1 the Signal-to-Noise Ratio (SNR) could be too low.
% So a constant to reduce Noise level is necessary.
%
NoiseReduc_0 = 10;
NoisePUser_N = randn(1,TxBits_n)/NoiseReduc_0;
NoiseUser1_N = randn(1,TxBits_n)/NoiseReduc_0;
NoiseUser2_N = randn(1,TxBits_n)/NoiseReduc_0;
% Channel Attenuation Gain (multiplier): different for every User/channel,
% no variation on time. Attenuation is inversely proportional to the power
% and directly proportional to squared distance.
% As the allocated power is proportional to squared distance: Pwr ~ Dst^2,
% it makes all Attenuations become a "boring" constant (0.71 in this case).
% So a random System Loss inversely proportional to power was included to
% increase the unpredictability of simulation.
%
SyLosPUser_00 = 1 + rand/(10*PwrPUser_pp);
AtnGnPUser_00 = TotPwrBS_00/PwrPUser_pp * 1/SyLosPUser_00;
AtnGnPUser_00 = AtnGnPUser_00*(DstBStoPUser_dp^2)/(MaxDsttoUser_00^2);
AtnGnPUser_00 = 1 - AtnGnPUser_00;
SyLosUser1_00 = 1 + rand/(10*PwrUser1_p1);
AtnGnUser1_00 = TotPwrBS_00/PwrUser1_p1 * 1/SyLosUser1_00;
AtnGnUser1_00 = AtnGnUser1_00*(DstBStoUser1_ds1^2)/(MaxDsttoUser_00^2);
AtnGnUser1_00 = 1 - AtnGnUser1_00;
SyLosUser2_00 = 1 + rand/(10*PwrUser2_p2);
AtnGnUser2_00 = TotPwrBS_00/PwrUser2_p2 * 1/SyLosUser2_00;
AtnGnUser2_00 = AtnGnUser2_00*(DstBStoUser2_ds2^2)/(MaxDsttoUser_00^2);
AtnGnUser2_00 = 1 - AtnGnUser2_00;
%=============================================================================
%%%Signal received by each User
%=============================================================================
% SMT: bit-lenght iteraction adding a Noise, increasing per bit - incorrect;
% Adding signal/(squared distance) - incorrect;
% for s=0.1:0.01:1 % noise variation
% N=s*randn(1,n);
% ys1=xs1/ds1.^2+N+xp/dp.^2+xs2/ds2.^2
% end
%
% NOMA: the Superposition Encoding (Enc_X) containing the messages to all
% Users already calculated above is affected by Attenuation (multiplier) and
% Noise (additive) just one time only as in Linear equation below:
%
% Yk(t) = X(t).Gk + Wk(t) where
%
% Yk(t) = superimposed signal received by User[k];
% X(t) = superimposed signal with all Users messages as transmitted by BS;
% Gk = channel attenuation gain for the link between BS and User[k];
% Wk(t) = additive White Gaussian Noise (AWGN) at the User[k] with
% mean ZERO and density N0;
%
RxSgnPUser_ysp = Enc_X*AtnGnPUser_00 + NoisePUser_N;
RxSgnUser1_ys1 = Enc_X*AtnGnUser1_00 + NoiseUser1_N;
RxSgnUser2_ys2 = Enc_X*AtnGnUser2_00 + NoiseUser2_N;

  10 Comments

thanks so much
if you have matlab code for capacity maximizing for non orthogonal multiple access
Please share capacity maximizing for non orthogonal multiple access if you have
Dear Moor
Thank you due to you share matlab code. But I am curious about why you did not incorporate channel coefficients to the received signal at the receiver side.
Best regrads

Sign in to comment.


Answer by Tahir Arshad on 1 May 2018

hello sir, can you please share the matlab code for NOMA specially receiver side. thanks

  0 Comments

Sign in to comment.


Answer by Thanh Nguyen on 21 Apr 2017

I am not sure whether my answer can help you about the NOMA.
Firstly, generate the bit sequences for each user separately and then modulate them by a common modulation scheme like QPSK. In this step, the signal for each users is considered equally in power.
Secondly, combine the signals into one stream (I call NOMA modulation in power domain, or in some papers they call Superposition Encoding). In this step, we have to consider the Power Allocation for each user s' signal (reference to others NOMA papers for more detail).
Finally, the sole signal will be transmitted as the same way as you described.
Let consider my suggested pseudo code:
clc;
clear all;
n=100;%n0.0f bits for transmit signal
%%%the signal from the BS
xp=rand(1,n); % signal stream of primary user
pp=0.5; % power allocation for primary user
xs1=rand(1,n); % signal stream of user 1
p1=0.3; % power allocation for user 1
xs2=rand(1,n); % signal stream of user 2
p2=0.2; % power allocation for user 2
%superposition encoding
X=sqrt(pp)*xp+sqrt(p1)*xs1+sqrt(p2)*xs2;

  6 Comments

All those **** are invalid MATLAB syntax; your program cannot run.
i have removed ** it still does not work. Sir Robert, do you have any idea about Simulation Code of Non-Orthogonal Multiple Access (NOMA) ?
[MOVED from flags] Chu Duc Hanh wrote on 22 Oct 2018 at 22:48.
Em chào anh, em đang làm luận án liên quan đến NOMA và có một số câu hỏi muốn hỏi anh được không ạ?
Translation for the readers:
Hello, I'm doing a dissertation related to NOMA and have some questions to ask him?
@Chu Duc Hanh: Please use the section for comments to post such a comment. Thanks.

Sign in to comment.


Answer by simith
on 24 Nov 2017

Hi; How to apply The Rice's Formula to find the number of crossings? Pls tell me matlab code for that

  3 Comments

if there is matlab code for power allocation for non orthogonal multiple access
please send it

Sign in to comment.


Answer by Daniel Demessie on 9 Apr 2019

thanks so much if you have matlab code for Spectrally efficient Non-Orthogonal Multiple Access (NOMA) please send it

  1 Comment

This is not answer to the question. Please do not hijack other threads by posting pseudo-answers.

Sign in to comment.