whats preventing my code from generating the proper results

1 view (last 30 days)
hello i coded in matlab the following equation:
the plot should be similar to this:
my code is blow, i uncluded the code to plot NLOS(lower bound) so we can use it as a reference
the equation for NLOS LOWER BOUND is:
% Define parameters
M_array = 1:50; % Number of BS antennas
SNR0_dB = 0; % SNR of the desired UE (in dB)
SNR0 = 10.^(SNR0_dB/10); % SNR of desired UE (in linear scale)
beta_bar_dB = -10; % Inter-cell interference strength (in dB)
beta_bar = 10.^(beta_bar_dB/10); % Inter-cell interference strength (in linear scale)
dH = 1/2; % Half-wavelength spacing for ULA
pi = 180;
num_realizations = 5000;
% Calculate SE_NLOS_LOWER_BOUND
SE_NLOS_LOWER_BOUND = log2(1 + ((M_array-1) ./ (beta_bar + (1/SNR0))));
% Calculate SE_LOS for each M and UE angle pair
SE_LOS = zeros(1, length(M_array));
for i = 1:length(M_array)
G = zeros(1, num_realizations);
for j = 1:num_realizations
Q = 2*pi *randn( );
W = 2*pi *randn( );
if sind(Q) ~= sind(W)
G(j) = (sind(pi*dH*M_array(i)*(sind(Q)-sind(W))))^2/(M_array(i)*(sind(pi*dH*(sind(Q)-sind(W))))^2);
else
G(j) = M_array(i);
end
end
SE_LOS(i) = mean(log2(1 + M_array(i)/(beta_bar*mean(G) + 1/SNR0)));
end
% Plot the results
grid on; hold on;
plot(M_array, SE_LOS,'red');
plot(M_array, SE_NLOS_LOWER_BOUND,'blue');
% ,'NLOS'
xlabel('Number of BS antennas (M)');
ylabel('Average SE (bits/s/Hz)');
legend('LoS','NLOS LOWER BOUND','Location', 'northwest');
plot results are as follow:
i dont understand why the LOS curve dips under the NLOS_LOWER_BOUND curve, as it's shown in the figure im trying to replicate, LOS curve should stay greater than NLOS_LOWER_BOUND throughout, also there's crukidness in the LOS curve at higher M values but i believe it can be eliminated by increasing the number of realization (i only used 5000 because higher values take too long to compute), i also have M_array = 1:50 instead of 1:100 to conserve time because it takes too long to compute.
i would love to know whats the error in my code, and of course all help is greatly appreciated

Answers (1)

Alan Stevens
Alan Stevens on 11 Jun 2023
I don't know anythng about the physics of your scenario, but are you sure you are calculating NLOS_LOWER_BOUND correctly? The following, for example seems to get closer to what you want:
% Define parameters
M_array = 1:50; % Number of BS antennas
SNR0_dB = 0; % SNR of the desired UE (in dB)
SNR0 = 10.^(SNR0_dB/10); % SNR of desired UE (in linear scale)
beta_bar_dB = -10; % Inter-cell interference strength (in dB)
beta_bar = 10.^(beta_bar_dB/10); % Inter-cell interference strength (in linear scale)
dH = 1/2; % Half-wavelength spacing for ULA
% pi = 180; Really?!!!!!
num_realizations = 50000;
% Calculate SE_NLOS_LOWER_BOUND
% SE_NLOS_LOWER_BOUND = log2(1 + ((M_array-1) ./ (beta_bar + (1/SNR0))));
% Calculate SE_LOS for each M and UE angle pair
SE_LOS = zeros(1, length(M_array));
SE_NLOS_LOWER_BOUND = zeros(1, length(M_array));
for i = 1:length(M_array)
G = zeros(1, num_realizations);
for j = 1:num_realizations
Q = 2*pi*randn(1);
W = 2*pi*randn(1);
if abs(sin(Q) - sin(W)) > 1E-8
arg1 = pi*dH*M_array(i)*(sin(Q) - sin(W));
arg2 = pi*dH*(sin(Q) - sin(W));
G(j) = sin(arg1)^2/(M_array(i)*sin(arg2)^2);
else
G(j) = M_array(i);
end
end
Gm = mean(G);
SE_LOS(i) = (log2(1 + M_array(i)/(beta_bar*Gm + 1/SNR0))); %
SE_NLOS_LOWER_BOUND(i) = log2(1 + (M_array(i)-1)/(beta_bar*Gm + 1/SNR0));
end
% Plot the results
grid on; hold on;
plot(M_array, SE_LOS,'red');
plot(M_array, SE_NLOS_LOWER_BOUND,'blue');
% ,'NLOS'
xlabel('Number of BS antennas (M)');
ylabel('Average SE (bits/s/Hz)');
legend('LoS','NLOS LOWER BOUND','Location', 'northwest');
By the way, pi is an in-built constant. It's not a good idea to re-define it!
  1 Comment
Fares Zaritt
Fares Zaritt on 11 Jun 2023
thank you for your response good sir!
i also apologize for forgeting to include the NLOS LOWER BOUND
the lower bound equation is the the highlighted part,
by writing the lower bound equation with: beta_bar*Gm
it becomes: SE_NLOS_LOWER_BOUND(M) = SE_LOS(M-1)
i didn't doubt the LOWER BOUND equation code because i managed to code the NLOS equation (represented by the blue curve in the original figure) and they didnt contradict each other, i refrained from mantioning NLOS because i thought it would only serve to needlessly complicate my post, i mean look:
it's code is:
clear all
% parameters:
M_array = 1:100; % Number of BS antennas
SNR0_dB = 0; % SNR of the desired UE (in dB)
SNR0 = 10.^(SNR0_dB/10); % SNR of desired UE (in linear scale)
beta_bar_dB = -10; % Inter-cell interference strength (in dB)
beta_bar = 10.^(beta_bar_dB/10); % Inter-cell interference strength (in linear scale)
% % % Average SE in NLOS, formula (1.29) on page (184)
sum3=0;sum2=0;sum1=0;
for kk = 1:length(M_array)
M = M_array(kk);
A = 1./( (1-1/beta_bar).^M );
A = A-1;
B = exp(1./(SNR0*beta_bar)).*expint(1./(SNR0*beta_bar));
C = A.*B;
C = C/log(2);
for m = 1:M
for L = 0:M-m
for n = 1:L
for j = 0:n-1
sum3 = sum3 + 1/(factorial(j) .* (SNR0).^j) ;
end
sum2 = sum2 + (1/n)*sum3 ;
sum3 = 0 ;
end
D = (exp(1./SNR0).*expint(1./SNR0));
E = D + sum2;
sum2 = 0;
sum1 = sum1 +(( (-1).^(M-m-L+1) ).* E )./...
( ((1 - 1./beta_bar).^m) .*...
( factorial(M-m-L) .* SNR0.^(M-m-L) .* beta_bar.*log(2) ) );
end
end
SE_NLOS(kk) =sum1;
sum1 = 0;
end
% figure
plot(M_array, SE_NLOS ,'green');
xlabel('Number of BS antennas (M)');
ylabel('Average SE (bits/s/Hz)');
i refrained from explaining the physiques of what im dealing with because i thought its irrelevent to the execution of the code itself
(these equations study the effect of increasing the number of antennas (M) of the base station on the spectral effeciency SE, spectral effeciency is a term used in wireless communication, it measures how good a system is at transferring data,
LOS: Line Of Sight scenario
NLOS: No Line Of Sight scenario)
also i wrote pi=180 because i used sind() (which calculates using degree) but still wrote pi instead of 180, i was too lazy to change every pi to 180 so instead wrote that
(i was yet to discover maj+ent back then)
% pi = 180; Really?!!!!!
this stung ngl XD
again thank you for your answer and i hope this clarifies things more

Sign in to comment.

Categories

Find more on Analysis, Benchmarking, and Verification in Help Center and File Exchange

Products


Release

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!