What’s the possible reason for my Failed status?

%
% % save_file_name = [‘ULDL_rate_Massive_’,my_date,‘Kul’,num2str(Kul),…
clc
clear all

M = 4 ;
K = 1:M;

% theta_r_0 = diag(K); %constant first phase
% theta_t_0 = diag(K);

theta_t_0=exp(j.*rand(M,M).*2.*pi);
theta_r_0=exp(j.*rand(M,M).*2.*pi);

NR = 4; % recive antenna
NT = 4; % transmit antenna

% n = 0;
w = 2 ;
Pe_vdb = 0:2:4; %dB
Pe_v = 10.^(Pe_vdb./10); %watt
Ne =( 10.^(-30./10));
Nd = (10.^(-30./10));
Ps = 10.^(40./10);
sap =(10.^(-10./10));

itration = 4;
d_RE = sqrt(34); %distance of R & E (m)
d_SR = sqrt(43); %distance of S & R (m)
d_SD = 6; %distance of S & D (m)
d_RD = sqrt(43); %distance of R & D (m)
d_ER = sqrt(34); %distance of E & R (m)

t = 2.2 ; %tawPL_0=10^(-30/10);
PL_0=10^(-10/10);

p11= PL_0*((d_RD)^(-t));
p22 = PL_0*((d_SR)^(-t))
p33 = PL_0*((d_SD)^(-t))
p44 = PL_0*((d_ER)^(-t))
p55 = PL_0*((d_RE)^(-t))

theta_r_h_0 = diag(theta_r_0)‘;
theta_t_h_0 = diag(theta_t_0)’;
%
theta_r_bar_0 = [theta_r_h_0 1];
theta_t_bar_0 = [theta_t_h_0 1];

Qr_n= (theta_r_bar_0)'(theta_r_bar_0);
Qt_n = (theta_t_bar_0)'
(theta_t_bar_0);

Qr_n_TZF= (theta_r_bar_0)'(theta_r_bar_0);
Qt_n_TZF = (theta_t_bar_0)'
(theta_t_bar_0);

Ex = zeros(1,length(Pe_vdb));

for ii = 1:length(Pe_vdb)

ii
Q_E = Pe_v(ii);
c  = 0;    
j  = 0; 
c1  = 0; 
c2  = 0; 
c3  = 0; 

for i = 1:itration

ro1 = .01;
ro2 = .01;

  flag = 0;
         
  h_RD = sqrt(p11)*( (1/sqrt(2*((d_RD)^(t))))*(randn(1,M)+sqrt(-1)*randn(1,M)) );

  h_SR = sqrt(p22)*( (1/sqrt(2*((d_SR)^(t))))*(randn(M,1)+sqrt(-1)*randn(M,1)) );

  h_SD = sqrt(p33)*( (1/sqrt(2*((d_SD)^(t))))*(randn(1,1)+sqrt(-1)*randn(1,1)) );

  H_ER = sqrt(p44)*( (1/sqrt(2*((d_ER)^(t))))*(randn(M,NT)+sqrt(-1)*randn(M,NT)) );

H_ER_new = (sqrt(Q_E/Ne))*H_ER ;

  H_RE = sqrt(p55)* ( (1/sqrt(2*((d_RE)^(t))))*(randn(NR,M)+sqrt(-1)*randn(NR,M)) );

H_RE_new = (sqrt(Q_E/Ne))*H_RE ;

  H_EE = sqrt(sap)*( (1/sqrt(2))*(randn(NR,NT)+sqrt(-1)*randn(NR,NT)) );

   
   maxro_t = 1.0000e-08;
   maxro_r = 1.0000e-08; 

% flag = 0;
while maxro_t< 1.0000e-07 && maxro_r<1.0000e-07

      a  = theta_r_0;
    b  = theta_t_0; 
 
     for n = 1:4
      u = H_EE + H_RE*a*H_ER ;  
      u_new = (sqrt(Q_E/Ne))*u; 

y_max = 1 + (Q_E/Nd)( ( norm( h_RDb*H_ER) ).^2 );

for z = 1:5;
y = 1 + (y_max./5).*(z-1);

   %............. Optimization Problem ..............
      
      cvx_begin  quiet
      variable Z(NT,NT) hermitian;
      variable s;
      variable f_y;
         
      dual variables p1 p2 p3 p4 p5 

      minimize f_y; 
      
      subject to
      
      p1: s == hermitian_semidefinite(1);
      p2: trace(Z) == s;
      p3: s + trace(Z*( u_new'  )*(  u_new ) ) == 1
      p4: trace(Z*(H_ER_new'*b'*h_RD'*h_RD*b*H_ER_new)) == s .* (y-1)
      p5: Z == hermitian_semidefinite(NT)
          f_y -  trace(Z*(u'*H_RE_new*b*h_SR*h_SR'*b'*H_RE_new'*u))== hermitian_semidefinite(1)
      cvx_end

 if( strcmp( cvx_status, 'Infeasible' ) == 1 );
         
         Exy(z) = 0;
     else
         Exy(z) = f_y + ( ((Ne/Nd).*(abs(h_SD + h_RD*a*h_SR)^2))./y) ; 
     end       

end

E_xy = nonzeros(Exy);
[l,e] = min(E_xy) ;

       if mean(Exy) ~= 0
           
           j = find(Exy==l);
       end
       
      y = 1 + (y_max-1)/5*(j-1);

cvx_begin quiet
variable Z(NT,NT) hermitian;
variable s;
variable v;

      dual variables p1 p2 p3 p4 p5 

      minimize v ; 
      
      subject to
      
      p1: s == hermitian_semidefinite(1);
      p2: trace(Z) == s;
      p3: s + trace(Z*( u_new'  )*(  u_new ) ) == 1
      p4: trace(Z*(H_ER_new'*b'*h_RD'*h_RD*b*H_ER_new)) == s .* (y-1)
      p5: Z == hermitian_semidefinite(NT)
          v -  trace(Z*(u'*H_RE_new*b*h_SR*h_SR'*b'*H_RE_new'*u))== hermitian_semidefinite(1)
      cvx_end
      %% .......................... W and w_t .............................
     if length(cvx_status)==6 && sum(cvx_status == 'Solved')==6;
         W     = Z/s ;
         h_t   = real(cvx_optval);
         [V D] = eigs(W);
         d     = real(diag(D));
         [d I] = sort(d,'descend');
         w_opt = V(:,I(1));
         W_opt = W;
     else
         w_opt = zeros(NT,1);
         W_opt = zeros(NT);
         h_t   = 0;
     end
       
      if W_opt == zeros(NT)
          flag = 1;
          break 
      end 
     
     
     A = Q_E*( H_EE*w_opt + H_RE*a*H_ER*w_opt )*( (H_EE*w_opt + H_RE*a*H_ER*w_opt)')+eye(NR);
       
     Wr = inv(A)*H_RE*b*h_SR/((norm(inv(A)*H_RE*b*h_SR)));
       

      ak1 = ( diag(h_RD) )*h_SR;
      ak1_bar = [ak1',h_SD']' ;
      Ak1 = ak1_bar*(ak1_bar');

      
      ak2 = ( diag(h_RD) )*H_ER*w_opt ;
      ak2_bar = [ak2',0]';
      Ak2 =  ak2_bar*(ak2_bar') ;


      ak3 = ( diag(Wr'*H_RE) )*h_SR;
      ak3_bar = [ak3',0]';
      Ak3 = ak3_bar*(ak3_bar');

      
      ak4 = ( diag(Wr'*H_RE) )*H_ER*w_opt;
      b1 = Wr'*H_EE*w_opt;
      ak4_bar = [ak4',b1]';
      Ak4 = ak4_bar*(ak4_bar');  
         
         
         
      %............. Optimization Problem ..............            

           cvx_begin  quiet

           variables x y T 
           variable Qt(M+1,M+1)  
           variable Qr(M+1,M+1)      

norm_2_Qt_n = norm(Qt_n);
norm_2_Qr_n = norm(Qr_n);

normnuc_Qt = norm_nuc(Qt_n);
normnuc_Qr = norm_nuc(Qr_n);

         [Utt Rtt] = eigs(Qt_n,1,'LM');              
          Ut = abs(Utt);

          [Urr Rrr] = eigs(Qr_n,1,'LM');
          Ur = abs(Urr);
          
          Qt_bar_n = real(norm_2_Qt_n+trace(Utt*Utt'*(Qt-Qt_n)));

          Qr_bar_n = real(norm_2_Qr_n+trace( Urr*Urr'*(Qr-Qr_n)));

          
          
          t1= square( trace(Ak3*Qt)-trace(Ak2*Qt) );
          t2 = real( (-2)*( trace(Ak3*Qt_n)+trace(Ak2*Qt_n) )*( trace(Ak3*Qt)+trace(Ak2*Qt) ) ) ;
          t3 = real((trace(Ak3*Qt_n)+trace(Ak2*Qt_n))^2) ;
          
          t6 = real((-2)*( trace(Ak4*Qr_n)-trace(Ak1*Qr_n) )*( trace(Ak4*Qr)-trace(Ak1*Qr) ));
          t7 = real(( trace(Ak4*Qr_n)-trace(Ak1*Qr_n) )^2);
          
          
          T == [x y];

          minimize ( prod_inv(T)+ro1*( norm_nuc(Qt)- Qt_bar_n )+ro2*( norm_nuc(Qr)-Qr_bar_n) );

          subject to 

          4*inv_pos(x)+square( trace(Ak3*Qt)-trace(Ak2*Qt) )+t2+t3 <= 0;

          square( trace(Ak4*Qr)+trace(Ak1*Qr) )+t6+t7-4*y <= 0;

%
Qt>=0;
Qr>=0;

          diag(Qr)+diag(Qt)==ones(M+1,1)
          cvx_end
          
          cvx_status

if ( strcmp( cvx_status, ‘Failed’ ) == 1 );
flag =1;
break
end
Qr_n = Qr;
Qt_n = Qt;

           th_bar_r = sqrt(diag(Qr))';
           th_tilr = th_bar_r(:,1:end-1);
           theta_r0 = diag(th_tilr');


           th_bar_t = sqrt(diag(Qt))';
           th_tilt = th_bar_t(:,1:end-1);
           theta_t0 = diag(th_tilt');

          
          a = theta_r0;
          b = theta_t0;

end

     if flag 
         break 
     end
         ro1 = w*ro1;
         ro2 = w*ro2;
         
         
         Qt_n = Qt;
         Qr_n = Qr;
         
         maxro_t = max( norm_nuc(Qt_n) - norm(Qt_n) ); 
         maxro_r = max( norm_nuc(Qr_n) - norm(Qr_n) ); 

end
if flag
SINR_d = 1;
SINR_e = 0;
else

     SINR_d = Ps*(abs(h_SD + h_RD*a*h_SR)^2)/(Q_E*(abs( h_RD*b*H_ER*w_opt)^2) + Nd)
       SINR_e = Ps*(abs(Wr'*H_RE*b*h_SR)^2)/(Q_E*(abs(Wr'*H_EE*w_opt + Wr'*H_RE*a*H_ER*w_opt )^2) + Ne)

     end  
       
         if SINR_e >= SINR_d;
        
        c = c + 1
         end
end
Ex(ii) = c./itration; 

end

xq2 = 0:0.01:8;
p1 = pchip(Pe_vdb,Ex,xq2);
plot(xq2,p1,‘-’)
hold on
grid on
box on

If you remove quiet, you’ll see the solver and CVX output. you should also look at the optimal values of CVX variables for those iterations in which Solved status is reported.

As to what’s going on, here’s a guess.