Hi

I wanna simulate this GP in MATLAB

I try to model this, but there is some errors that I can’t fix it.

```
clear all;
clc;
N_antenna=200; %number of antennas
N_usersr=20; %number of users
N_BS=4; %number of B.Ss
loop=3;
shadow_fading=7; %in dB
noise_dB=-96; %in dBm
noise=10^(noise_dB/10);
P_max_dB=23; %in dBm
Pmax=10^(P_max_dB/10);
tau_p=N_usersr;
tau_c=200; %coherent interval
radius=1;
QoS=landa=0.5:0.5:2; %bit/Hz/s
%nbrOfRealizations=10;
Pp=200; %pilot power in mW
%QoS=2.^(QoS*tau_c/(tau_c-tau_p))-1;
%%
Comp_MRT_fixNa=zeros(length(QoS),N_usersr);
Comp_ZF_fixNa=zeros(length(QoS),N_usersr);
for iter=1:loop
%generate BS location
for i=1:4
BS_locations(i,:)=[cos(i*pi/2) sin(i*pi/2)]/2;
end
%generate UE location
rng('shuffle'); %Initiate the random number generators with a random seed
minimal_dist=0.035;
%for iter =1: nbrOfRealizations
% iter
UserLocationLargeScale = zeros(N_usersr,1);
% Step 1: Generate user locations
% Uniformly distributed users in the network
distance_normalized = 2*minimal_dist+sqrt(rand(N_usersr,1));
angles = rand(N_usersr,1)*2*pi;
%%
% Generate MS locations
MS_locations = (radius/2)*repmat(distance_normalized,[1 2]).*[cos(angles) sin(angles)];
% Tolerance to stopping optimizat
% MSlocationSave(:,:,iter)=MSlocations;
MSlocationSave=MS_locations;
for k=1:N_usersr
dista(k,:) = sqrt(sum(abs(BS_locations -repmat(MS_locations(k,:),[N_BS 1])).^2,2));
% Go through all transmitters
for j=1 :N_BS
end
%large scale fading
largescale_fading_dB=-131-42.8.*log10(dista)+shadow_fading;
beta=10.^(largescale_fading_dB/10);
gamma=tau_p*Pp.*(beta).^2./(tau_p*Pp.*beta+noise);
end
[value ind]=min(dista');
for k=1:length(QoS)
%% code for optimizing max snr MRT
cvx_begin gp
cvx_quiet true
variables PmaxsnrMRT(N_usersr) landa %nonnegative
maximize landa
subject to
for i=1:N_usersr
10^22*(PmaxsnrMRT(i).*gamma(i,ind(i))*200) >= 10^22*(landa*(noise+sum(PmaxsnrMRT'*(beta))));
PmaxsnrMRT(i)<= Pmax;
PmaxsnrMRT(i) >=0;
end
cvx_end
PfixQoS_maxSnr(iter,k)=sum(PmaxsnrMRT);
end
end
save('PfixQoS_maxSnr')
```