whats preventing my code from generating the proper results
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Alan Stevens
el 11 de Jun. de 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 comentario
Ver también
Categorías
Más información sobre Analysis, Benchmarking, and Verification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!