Why does iterative optimisation result in a value of 0

I’m writing a code for convex optimization problem with CVX (matlab ),how can I solve it?
close all;
clear all;clc;
% ave_snrdB = -10:2.5:20;
% ave_snr = 10.^(ave_snrdB/10);
P_theta = 10^(-12)*[100 56.234 31.623 17.783 10 5.6234 3.1623 1.7783 1 0.5623 0.3162 0.1778 0.1000 0.0562 0.0316 0.0178 0.01];

Ns = 2; Nut = 1; Nur = 1;
N1=2;N2=2;

%莱斯信道(无人机到地面)
d1=100;theta1=30;
G_1os=Los_channel(theta1, Nut, 1, d1);K=0.7;
%Los信道(卫星到无人机)无人机有2个
d2=10^6;theta2=60;hu1 =Los_channel(theta2,Ns, 1,d2);
theta3=50;hu2 =Los_channel(theta3,Ns, 1,d2);
H_u=[hu1;hu2];
% 无人机到的窃听者 LOS 信道 无人机有2个
d3 =10^3; theta5 = 35;theta6 = 65; % 窃听者到无人机的视角
h1e = Los_channel(theta5, Nut, 1, d3);h2e = Los_channel(theta6, Nut, 1, d3); % 计算窃听者到无人机的 LOS 信道矩阵
h_ue=[h1e;h2e];
% 卫星到窃听者的 LOS 信道
d4 = 10^5; theta4 = 75; % 窃听者到卫星的视角
h_e = Los_channel(theta4, Ns, 1, d4);h_e =h_e’; % 计算窃听者到卫星的 LOS 信道矩阵
sigma_n=110^(-3);
rayleigh_part =sigma_n
sqrt(1/2)(randn(2, 1)+ 1i * randn(2, 1));
h_ud= sqrt(K/(K+1))G_1os + sqrt(1/(K+1)) rayleigh_part;

Ps = 1;

for snr =17%1:length(P_theta)
p0 = [1;2];
w=[1;1];
% w=w*(sqrt(Ps/trace(w’*w)));
% sigma = sqrt(1./(ave_snr(snr))); sigma_u=sigma;sigma_e=sigma;sigma_d=sigma;sigma_n=1;
sigma_u= sqrt(P_theta(snr));
sigma_e= sqrt(P_theta(snr));
sigma_d= sqrt(P_theta(snr));

    gaps=0.01;SR0=0.01;
    while abs(gaps)>=0.0001
        % 定义 CVX 优化问题
        cvx_begin
        cvx_solver mosek
        cvx_precision default
        variable p(Ns, Nut)  complex
        variable r1
         variable r2
        g=r1-r2;

        maximize g
        subject to
      
                A=H_u'*diag(conj(h_ud))*conj(w)*w.'*diag(h_ud)*H_u;
                a=quad_form(p0, A);
                b1=a+2*real(p0'*A*(p-p0));
                b2=sigma_d^2+sigma_u^2*w.'*diag(h_ud)*diag(conj(h_ud))*conj(w);
                b=b1/b2;
                c=(conj(h_e)*h_e.')/sigma_e^2;d=sigma_e^2+sigma_u^2*w.'*diag(h_ue)*diag(conj(h_ue))*conj(w);
                B=real(c+A/d);
                m=quad_form(p0, B);
                n=quad_form(p, B);
                r1 <= (log(real(1+b)/log(2)));                   
                r2 >= (log(1+m)/log(2)+(n-m)/((1+m)*log(2)));
     
                square_pos(norm(p,'fro'))<=Ps;
                cvx_end
                
                p0=p;
                SR1=g;
                gaps=SR1-SR0;
                SR0=SR1;
       end

end

I want to optimise for p.I am fixing w,optimising p, given an initial value for p0. After two iterations of this code update, the optimised variable p becomes 0, however, this is not the result I want to get.

You are not trying to solve a convex optimization problem with CVX. You are trying to solve a non-convex optimization problem by calling CVX within some type oif SCA or alternating variables algorithm. Note that if you use a different initial value of p0, you might get different results, maybe better, maybe not.