function[Pr,Rr]=SolveP1(Qr)
global beta0 H N0 N1 N2 Fc V L d0 tolerance P_ave p1 p2 M SNR R S;
L=2000;
H=100;
N1=-169;
N2=-169;
P_ave=5;
beta0=10; %
l=0;
tolerance=0.00001;
tol=tolerance;
M=100;
m = 1 : 1: M;
Q(1,m) = ((2000 - 0)(m-1)/(M-1));
Q(2,m)=((2000 - 0)(m-1)/(M-1));
Qr=Q;
for l=1:1000
itera=l
P_begin=4*ones(2,M);%
P1={P_begin}%
%初始化轨迹;
h_ub=beta0ones (1,M)./((Qr(1,:)-Lones(1,M)).^2+(Qr(2,:).^2)+Hones(1,M).^2); %this is a 1m matrix
h_au=beta0ones(1,M)./((Qr(1,:).^2)+(Qr(2,:).^2)+(Hones(1,M).^2));%this is a 1*m matrix
cvx_begin gp
variable P(2,M);
expression S;
expression R_con;
minimize -sum(R_con);
subject to
sum(P(1,:))<=M*P_ave; %average power constrains
sum(P(2,:))<=M*P_ave;
P(1,:)>=0;
P(2,:)>=0;
SNR=((P(1,:).*P(2,:).*h_au .*h_ub)) ./( ((P(1,:).*h_au.*(N2*ones(1,M)) +P(2,:).*h_ub.*(N1*ones(1,M))+(N1*ones(1,M)).*(N2*ones(1,M)))));
SNR1=(P1{1}(1,:).*P1{1}(2,:).*h_ub.*h_au)./((P1{1}(1,:).*h_ub.*N2*ones(1,M))+P1{1}(2,:).*h_ub.*N1*ones(1,M)+N1*ones(1,M)*N2*ones(1,M));
S=((SNR.^2*log2(e)*ones(2,M))./(2*(SNR1+1))).*(ones(2,M)./SNR -(ones(2,M)./SNR1));
R = (1/2*ones(2,M) * log2(1+P1{1}));%initial
R_con=R(l)-S;
cvx_end
P_l_ite=P;
R_l_ite=sum(R_con);
R = [R; R_l_ite];
P1 = cat(1, P1, {P_l_ite});
if (l >= 2) &&(R(l) - R(l-1) < tol) %l is the times of iteration
break;
end
end
Pr = P;
Rr = sum(R_con);
end
it was the frist to use cvx to solve problem ,i am sure that my model is convex ,i can not solve this problem as show above ,could please tell me why cvx did not accpet my model,thank you very much