user location assignment
muhammetp opened this issue · comments
for i = 1:L % k-th user in the j-th cell to i-th BS
for j = 1:L
for k = 1:K
x1 = BaseP(i,1);
y1 = BaseP(i,2);
% x2 = random('unif', 0, 2R_Cell, 1, 1);
% y2 = random('unif', 0, 2R_Cell, 1, 1);
% while ((x2-R_Cell)^2+(y2-R_Cell)^2>R_Cell^2) || ((x2-R_Cell)^2+(y2-R_Cell)^2<r_Min^2)
% x2 = random('unif', 0, 2R_Cell, 1, 1);
% y2 = random('unif', 0, 2R_Cell, 1, 1);
% end
x2 = random('unif', -R_Cell, R_Cell, 1, 1);
y2 = random('unif', -R_Cell, R_Cell, 1, 1);
while ((x2)^2 + (y2)^2 > R_Cell^2) || ((x2)^2 + (y2)^2 < r_Min^2)
x2 = random('unif', -R_Cell, R_Cell, 1, 1);
y2 = random('unif', -R_Cell, R_Cell, 1, 1);
end
x2 = x2 + BaseP(j,1);
y2 = y2 + BaseP(j,2);
r = sqrt((x1-x2)^2+(y1-y2)^2); % distance between UE and BS
z = 10^(random('norm', 0, 10^(sigma_shadow/20), 1, 1)/10);
Beta(k,i,j) = z/((r/R_Cell)^alpha+1);
H(:,k,i,j) = sqrt(Beta(k,i,j))1/sqrt(2)(random('norm', 0, 1, 1, M)+random('norm', 0, 1, 1, M)*1j);
end
end
end
As you can all users in all cell positions are updated for each base station H and Beta calculation. However, This positions must have been to fixed for each each base station H and Beta so
% k-th user in the j-th cell to i-th BS
for j = 1:L
for k = 1:K
for i = 1:L
Corrected for loop must have been like that
for j = 1:L
for k = 1:K
x2 = random('unif', -R_Cell, R_Cell, 1, 1);
y2 = random('unif', -R_Cell, R_Cell, 1, 1);
while ((x2)^2 + (y2)^2 > R_Cell^2) || ((x2)^2 + (y2)^2 < r_Min^2)
x2 = random('unif', -R_Cell, R_Cell, 1, 1);
y2 = random('unif', -R_Cell, R_Cell, 1, 1);
end
x2 = x2 + BaseP(j,1);
y2 = y2 + BaseP(j,2);
for i = 1:L
x1 = BaseP(i,1);
y1 = BaseP(i,2);
r = sqrt((x1-x2)^2+(y1-y2)^2); % distance between UE and BS
z = 10^(random('norm', 0, 10^(sigma_shadow/20), 1, 1)/10);
Beta(k,i,j) = z/((r/R_Cell)^alpha+1);
H(:,k,i,j) = sqrt(Beta(k,i,j))1/sqrt(2)(random('norm', 0, 1, 1, M)+random('norm', 0, 1, 1,
M)*1j);
end
end
end