`%% algorithm for optimum alpha

%% inputs

P = 10^((30-30)/10);

NN = linspace(5,22,18);% NUMBER OF ANTENNAS

K = 5; % Number of tags

sigma_n = 10^((-70-30)./10); % variance of noise

sigma_SI = 0.01;% power of RSI

iteration =100;

Rate = zeros(iteration,length(NN));

%% SCATTERED POINTS

% %% scattered points

r=10; %radius of disk

xx0=0; yy0=0; %centre of disk

%Simulate binomial point process

pointsNumber=5;

theta=2*pi*(rand(pointsNumber,1)); %angular coordinates

rho=r*sqrt(rand(pointsNumber,1)); %radial coordinates

%Convert from polar to Cartesian coordinates

[xx,yy]=pol2cart(theta,rho); %x/y coordinates of Poisson points

%Shift centre of disk to (xx0,yy0)

xx=xx+xx0;

yy=yy+yy0;

a = 2.7; % PATH LOSS COEFFICIENT

%Plotting

%scatter(xx,yy);

%xlabel(‘x’);ylabel(‘y’);

%axis square;

d1 = (xx(1)^2+yy(1)^2)^(-a);

d2 = (xx(2)^2+yy(2)^2)^(-a);

d3 = (xx(3)^2+yy(3)^2)^(-a);

d4 = (xx(4)^2+yy(4)^2)^(-a);

d5 = (xx(5)^2+yy(5)^2)^(-a);

for itr=1:iteration

itr

for q=1:length(NN)

N=NN(q);

%channels

h1=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;

h2=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;

h3=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;

h4=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;

h5=sqrt(0.5) * ( randn(N,1) + sqrt(-1)*randn(N,1)) ;

h_SI=sqrt(0.5) * ( randn(N,N) + sqrt(-1)*randn(N,N)) ;

%precoding and combiner

H = [h1, h2, h3, h4,h5];

G = H*inv(H’*H); %[h1, h2, h3, h4,h5];%H*inv(H’*H);

F = conj(H)*inv(transpose(H)*conj(H));%[h1, h2, h3, h4,h5];

e = 10^(-6);

%%

```
f1 = 0;
f2 = 0;
f3 = 0;
f4 = 0;
f5 = 0;
c_1 = 0;
c_2 = 0;
c_3 = 0;
c_4 = 0;
c_5 = 0;
```

for i=1:K

f1 =abs(transpose(H(:,1))*(F(:,i)))^2+f1;*

f2 =abs(transpose(H(:,2))(F(:,i)))^2+f2;

f3 =abs(transpose(H(:,3))*(F(:,i)))^2+f3;*

f4 =abs(transpose(H(:,4))(F(:,i)))^2+f4;

f5 =abs(transpose(H(:,5))*(F(:,i)))^2+f5;

```
c_1 = sigma_SI*abs(G(:,1)'*(F(:,i))).^2+ c_1;
c_2 = sigma_SI*abs(G(:,2)'*(F(:,i))).^2+ c_2;
c_3 = sigma_SI*abs(G(:,3)'*(F(:,i))).^2+ c_3;
c_4 = sigma_SI*abs(G(:,4)'*(F(:,i))).^2+ c_4;
c_5 = sigma_SI*abs(G(:,5)'*(F(:,i))).^2+ c_5;
```

end

c1 = (trace(F*F’)/P)**sigma_n*norm(G(:,1)).^2 + (trace(FF’)/P)*c_1;*

c2 = (trace(FF’)/P)*sigma_n*norm(G(:,2)).^2 + (trace(F*F’)/P)**c_2;*

c3 = (trace(FF’)/P)*sigma_n*norm(G(:,3)).^2 + (trace(FF’)/P)*c_3;*

c4 = (trace(FF’)/P)*sigma_n*norm(G(:,4)).^2 + (trace(F*F’)/P)**c_4;*

c5 = (trace(FF’)/P)*sigma_n*norm(G(:,5)).^2 + (trace(FF’)/P)*c_5;

Gamma_Tk = [f1,f2,f3,f4,f5];

C = [c1,c2,c3,c4,c5];

a = [0.078;0.078;0.078;0.078;0.078];

w = zeros(1,length(a));

it = 1;

R_s(it) =0;

while 1

for k=1:length(a)

den = [abs(G(:,k)’*H(:,1)).^2, abs(G(:,k)’*H(:,2)).^2, abs(G(:,k)’*H(:,3)).^2, abs(G(:,k)’*H(:,4)).^2,abs(G(:,k)’*H(:,5)).^2 ] ;

w(k) = abs(G(:,k)’*H(:,k))*sqrt(a(k)*Gamma_Tk(k))/(transpose(a)*(transpose(Gamma_Tk.*den))-a(k)*Gamma_Tk(k)*abs(G(:,k)‘*H(:,k)).^2+C(k));*

end

it = it+1;

cvx_begin quite

variable b(K);

maximize log(1+2w(1)*abs(G(:,1)’*H(:,1))*sqrt(b(1)**Gamma_Tk(1))-(w(1)^2)*(transpose(b)(transpose(Gamma_Tk.*den))-b(1)*Gamma_Tk(1)*abs(G(:,1)‘*H(:,1)).^2+C(1))) + …*

log(1+2w(2)*abs(G(:,2)’*H(:,2))*sqrt(b(2)**Gamma_Tk(2))-(w(2)^2)*(transpose(b)(transpose(Gamma_Tk.*den))-b(2)*Gamma_Tk(2)*abs(G(:,2)‘*H(:,2)).^2+C(2))) + …*

log(1+2w(3)*abs(G(:,3)’*H(:,3))*sqrt(b(3)**Gamma_Tk(3))-(w(3)^2)*(transpose(b)(transpose(Gamma_Tk.*den))-b(3)*Gamma_Tk(3)*abs(G(:,3)‘*H(:,3)).^2+C(3))) + …*

log(1+2w(4)*abs(G(:,4)’*H(:,4))*sqrt(b(4)**Gamma_Tk(4))-(w(4)^2)*(transpose(b)(transpose(Gamma_Tk.*den))-b(4)*Gamma_Tk(4)*abs(G(:,4)‘*H(:,4)).^2+C(4))) + …*

log(1+2w(5)*abs(G(:,5)’*H(:,5))*sqrt(b(5)**Gamma_Tk(5))-(w(5)^2)*(transpose(b)(transpose(Gamma_Tk.*den))-b(5)*Gamma_Tk(5)*abs(G(:,5)’*H(:,5)).^2+C(5)))

subject to

0.01 <= b <= 1;

cvx_end

```
a = b;
R_s(it) = cvx_optval;
if ~( e>= (R_s(it)-R_s(it-1)) )
break;
end
```

end

Rate(itr,q) = R_s(it);

end

end

Final_Rate = mean(Rate);

figure;

plot(NN, Final_Rate,‘LineWidth’, 1.5)