Matlab code to find network capacity throws error

I am trying to calculate network/users' capacity through the code below but I constantly get "Subscript indices must either be real positive integers or logicals". I have almost spent a decade finding solution to it without success. The error is at the Throughput_(j) part.
%%%Parameters
B = 20*10^6;
No = 0.1e-15;
N = No*B;
Pstatic = 50; %%Fixed power in the circuit in Watt
fc = 2*10^9; %% carrier frequency
ht = 30; %%Transmitter height
hr = 2; %%Receiver height
AP = 2; %%Number of nodes
UE = 4; %%Number of users
%%Calculating location between nodes and UEs
UserLocationX = randi(4, 1, 4);
UserLocationY = randi(4, 1, 4);
AccessPointX = randi(4, 1, 2);
AccessPointY = randi(4, 1, 2);
for p = 1:1:500; %%power allocation to users
for i = 1:AP;
for j = 1:UE;
compute_distance = pdist2([AccessPointX(:) AccessPointY(:)],[UserLocationX(:) UserLocationY(:)]);
%%%Calculating the pathloss
C_Rx = 3.2*(log10(11.75*hrx))^2 - 4.97;
pathloss_compute = 69.55+26.16*log10(fc)-13.82*log10(ht)-C_Rx+(44.9-6.55*log10(ht))*log10(compute_distance);
%%Calculating the capacity.....Error throws up here!!! "Subscript indices must either be real positive integers or logicals".
Throughput_(j) = B*log2(1 + p(j)*pathloss_compute/(p(j-1)*pathloss_compute + N));
end
end
end

Respuestas (1)

Image Analyst
Image Analyst el 22 de Jul. de 2018
Since you didn't supply hrx, we can't run your code to reproduce the error.
In the line
Throughput_(j) = B*log2(1 + p(j)*pathloss_compute/(p(j-1)*pathloss_compute + N));
you have j-1. Well, the first j is 1, so j-1 is zero. There is no zeroeth element of an array. I suggest you rethink what your algorithm is trying to do.

2 comentarios

Oladele Felix
Oladele Felix el 22 de Jul. de 2018
@Image Analyst, Sorry. The hrx is mistaken for hr, the receiver height which is 2. As I said, I want the algorithm to calculate the throughput of the network. That j-1 part seeks to calculate the interference from other users except user j. I'm not even sure if I correctly calculated the distance and pathloss between nodes and users either. Thanks
Oladele Felix
Oladele Felix el 25 de Jul. de 2018
In my opinion, if I want to find the throughput for two users, i.e UE = 2, the first user would be: Throughput_(1) = B.*log2(1 + p1.*pathloss_compute1./p1.*pathloss_compute1 + N)); while the second user would be: Throughput_(2) = B.*log2(1 + p2.*pathloss_compute2./(p1.*pathloss_compute2 + N));. So if I want to compute for i-th user, it should be: Throughput_(i) = B.*log2(1 + p(i).*pathloss_compute(i)./(p(i).*pathloss_compute(i-1)+ N)); according to Shannon capacity formular, T(i) = log2(1 + P(i)*G(i)/(∑_(j=1)^(i-1)Pj.*Gi +N)); where the term in sigma is the interference from other users.

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 22 de Jul. de 2018

Comentada:

el 25 de Jul. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by