function [optimal_x_UAV,optimal_y_UAV] = UAV_Location_Subproblem(N,M,N0,B,beta_U,beta_B,Rcmin,UE_x,UE_y,x_UAV_1,y_UAV_1,h_UAV,A1,p_ue,p_uav)

a = A1;

x = [UE_x’,UE_y’];

X_1 = [x_UAV_1’,y_UAV_1’];

cvx_begin

variable X(M,2);

variable tempt_Slack_var(1,M);

```
expression r(N,M);
expression C1(1,N);
expression r_uav_B(1,M);
expression tempt_C2(1,M);
expression C3(1,M);
for i=1:N
for j=1:M
r(i,j) = a(i,j)*B*log(1 + p_ue(i)*beta_U/(N0*(square_pos(norm(X_1(j,:)-x(i,:))) + h_UAV^2)))/log(2) - (p_ue(i)*beta_U/(log(2)*N0))*(1/(1+(p_ue(i)*beta_U/(N0*(square_pos(norm(X_1(j,:)-x(i,:))) + h_UAV^2))))) * ( square_pos(norm(X(j,:)-x(i,:))) - square_pos(norm(X_1(j,:) - x(i,:))) )/(square_pos(norm(X_1(j,:) - x(i,:)))+h_UAV^2)^2;
end
C1(i) = sum(r(i,:)) - Rcmin;
end
for m = 1:M
tempt_c_r = 0;
for i = 1:N
if a(i,m)==1
tempt_c_r = tempt_c_r + r(i,m);
end
end
r_uav_B(m) = B*log2(1 + p_uav(m)*beta_B / (pow_pos(norm(X),2) + h_UAV^2));
tempt_C2(m) = tempt_c_r - r_uav_B(m);
end
obj = sum(sum(r));
maximize(obj)
subject to
C1 >= 0;
tempt_C2 <= r_uav_B;
```

cvx_end

matlab error as follows

Disciplined convex programming error:

Cannot perform the operation: {positive constant} ./ {convex}

错 ./ (line 19)

z = times( x, y, ‘./’ );

出错 * (line 36)

z = feval( oper, x, y );

出错 / (line 15)

z = mtimes( x, y, ‘rdivide’ );

出错 UAV_Location_Subproblem (line 33)

r_uav_B(m) = B*log2(1 + p_uav(m)*beta_B / (pow_pos(norm(X),2) + h_UAV^2));