How to solve this error" cvx_end " solve( prob );

My matrix are fully agreed. But when I press start button, cvx results show that place where cvx_end is not matrix-agreed which I have no idea why such command would have the error and no clue to correct it. Please help me to figure it out. Gratefully thanks!

the error shows below:

Here’s my input parameters:
%% Parameters Initialization %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ‘1’ stands for source-relays; ‘2’ stands for relays-destination
N = 5; % array number of BS 维度必须为5,因为5条曲线
Nr = 6;
M = 10; % array number of STAR-RIS 10-50
M1=M/2;
K = 2; % number of users
SNR_dB = 10; % dBW
cof_L = 0.5; %coefficient of loop interference
cof_S = 0.5; %coefficient of self interference
cof =[cof_S;1];%select coeffient 21dimension
%%%%% noise
N0=10^((-174-30) / 10); %-174dBm
B=10^7; %10MHz
down_maxpower_all=20;
up_maxpower_all = 20;
% noise_maxpower_original = N0
B; % % W
noise_maxpower_original = 10^((-70-30) / 10);%-80dBm
power_max_dBm=10;
%% Simulation loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
num_loop =100;
num_iterative = 10;
load(‘H_UI_ALL’);
load(‘H_IU_ALL’);%初始化信道
load(‘H_IE_ALL’);
load(‘H_IB_ALL’);
load(‘H_BI_ALL’);
load(‘H_BB_ALL’);
load(‘H_UU_ALL’);

%Rate=zeros(K,length(rate_min_dB),100);%初始化速率矩阵用于保存参数。
SumRate1=zeros(num_loop,num_iterative,length(down_maxpower_all));

for loop = 1 : num_loop %从1开始循环
outerflag=1;
T1=cputime;
noise_maxpower=1;%噪声功率归一化
%%% For different 自变量 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf(’ loop | N | iteration \n’);
for i_p = 1 : length(down_maxpower_all)%不同N,M或不同发射功率
t0=cputime;
down_maxpower=down_maxpower_all;
up_maxpower=up_maxpower_all;

%%%%%  Initialize Fi for different mode(ES,MS and TS )  %%%%%%%%%%%%%%%
H_IB=H_IB_ALL(1:Nr,1:M,loop)/sqrt(noise_maxpower_original);%信道归一化

H_BI=H_BI_ALL(1:M,1:N,loop)/sqrt(noise_maxpower_original);

H_IU=H_IU_ALL(1:M,1:K,loop)/sqrt(noise_maxpower_original);

H_UI=H_UI_ALL(1:K,1:M,loop)/sqrt(noise_maxpower_original);

H_IE=H_IE_ALL(1:M,1:K,loop)/sqrt(noise_maxpower_original);

H_BB=H_BB_ALL(1:N,1:Nr,loop)/sqrt(noise_maxpower_original);

H_UU=H_UU_ALL(1,1:K,loop)/sqrt(noise_maxpower_original);
%clear Phi_1 Phi_2 Phi_i3 Phi_4 Phi_6 W_1 W_3
%%%%%  Initialize Fi for different mode(ES,MS and TS )  %%%%%%%%%%%%%%%
%%%%%  ES模式参数初始化  %%%%%%%%%%%%%%%
Phi_temp=randn(2,M) + sqrt(-1)*randn(2,M);
Phi_tamp=rand(1,M);
Phi_ramp=1-Phi_tamp;
Angle=rad2deg(angle(Phi_temp));
Angle(Angle<0)=Angle(Angle<0)+360;
Ang=deg2rad(Angle);
Phi_amp=[sqrt(Phi_tamp) ;sqrt(Phi_ramp)];%幅度初始化
Phi_ini_ES=Phi_amp.*exp(1j*Ang);%/sqrt(trans_maxpower/(M*K));%幅度初始化,均匀分布
Phi_ini_eES=sqrt(0.5).*exp(1j*Ang);%幅度各为0.5,_equal_ES.
Phi1(:,:,1)=full(Phi_ini_ES);%ESmode下的Fi迭代值
%Phi4(:,:,1)=full(Phi_ini_eES);%equalESmode下Fi的迭代值
%%%%%  MS模式参数初始化  %%%%%%%%%%%%%%%
Phi_Mtemp=randn(2,M1) + sqrt(-1)*randn(2,M1);
 Phi_Mtamp=rand(1,M1);
 Phi_Mramp=1-Phi_Mtamp;
 Phi_Mamp=[sqrt(Phi_Mtamp) ;sqrt(Phi_Mramp)];
Angle2=rad2deg(angle(Phi_Mtemp));
Angle2(Angle2<0)=Angle2(Angle2<0)+360;
Ang2=deg2rad(Angle2);
Phi_ini_MS=Phi_Mamp.*exp(1j*Ang2);
Phi2(:,:,1)=full(Phi_ini_MS);
%%%%%  TS模式参数初始化  %%%%%%%%%%%%%%%
Phi_ini_TS=exp(1j*Ang);
Phi3(:,:,1)=full(Phi_ini_TS);
%%%%%  conventional RIS参数初始化  %%%%%%%%%%%%%%%
%Phi_ini_cRIS=exp(1j*angle(Phi_Mtemp));
%Phi6(:,:,1)=full(Phi_ini_cRIS);

%%%%%  Initialize W   %%%%%%%%%%%%%%%
W_ini=randn(N,K)*sqrt(down_maxpower/(N*K));
W1(:,:,1)=full(W_ini);
W3(:,:,1)=full(W_ini);
%%%%%  Initialize F   %%%%%%%%%%%%%%%
F_ini=randn(K,Nr)*sqrt(up_maxpower/(K*Nr))+1i*randn(K,Nr)*sqrt(up_maxpower/(K*Nr));
F1(:,:,1)=full(F_ini);
F3(:,:,1)=full(F_ini);
%%%%%  Initialize a   %%%%%%%%%%%%%%%
a_ini=randn(1,K)*sqrt(down_maxpower/(1*K));
a(:,1)=full(a_ini);
%%%%%  Initialize uplink MMSE variable   %%%%%%%%%%%%%%%    
u_up(:,1)=ones(1,2);
%%%%%  Initialize downlink MMSE variable   %%%%%%%%%%%%%%%    
u_dwn(:,1)=ones(1,2);    

And here’s my code of the optimization problem:

function [Phi_opt,flag] = Generate_ES_Phi(cof,cof_L,N,Nr, M, K, H_IB, H_BI,H_BB,H_UU,…
H_IU, H_UI, H_IE,W_ini,F_ini, Phi_ini, u_up_ini,u_dwn_ini, …
a_ini,n,noise_maxpower, down_maxpower,up_maxpower)
%%% PCCP parameters initialization%%%%
Phi_total(:,:,1)=Phi_ini;
step=10;
scaler_max=max(200-n*20,100);
for n_outter=1:10
%scaler1=10;
scaler2=10;
Phi_innertemp=randn(2,M) + sqrt(-1)randn(2,M);%涓ょ鍙嶅皠绯绘暟锛屼絾鎬庝箞琛ㄧず鎴愪袱绉?
Angle2=rad2deg(angle(Phi_innertemp));
Angle2(Angle2<0)=Angle2(Angle2<0)+360;
Ang2=deg2rad(Angle2);
Phi_inner=exp(1j
Ang2);
Phi_innerv=Phi_inner;
for temp=1:20

cvx_begin %quiet
variable  Phi(K,M) complex
variable  elta(1,K) 
variable  deta(1,K)
variable  x(K,M)
variable  z(K,2*M)
expressions dwn(K) up(K) constrain(K) final_constra(K) POLY(K);

k=1:1:K;
u=K:-1:1;
    for i=1:1:length(k)
         if k(i)==1||u(i)==1 
            for L=1:1:K
                a=0.5;
                %%%%%%%%%%downlink term of MMSE%%%%%%%%%
                dwnlk_ch(:,k(i))=u_dwn_ini(k(i))*diag(H_IU(:,k(i)))*H_BI(:,:)*W_ini(:,L);
                dwnlk_poly(k(i))=sum(dwnlk_ch(:,k(i))'*dwnlk_ch(:,k(i)));
                dwnlk_ini(k(i))=Phi_ini(k(i),:)*dwnlk_poly(k(i))*Phi_ini(k(i),:)';

                dwnSI_ch(:,k(i))=u_dwn_ini(k(i))*diag(H_IU(:,k(i)))*H_UI(L,:)';
                dwnSI_poly(k(i))=cof(k(i))*up_maxpower*sum(dwnSI_ch(:,k(i))'*dwnSI_ch(:,k(i)));
                dwnSI_ini(k(i))=Phi_ini(k(i),:)*dwnSI_poly(k(i))*Phi_ini(k(i),:)';

                dwn_rlpt(:,k(i))=u_dwn_ini(k(i))*diag(H_IU(:,k(i)))*H_BI(:,:)*W_ini(:,k(i));

                dwn_const(k(i))=noise_maxpower*cof_L*up_maxpower*H_UU(k(i))*H_UU(k(i))*u_dwn_ini(k(i))*u_dwn_ini(k(i));
                
                dwn_aux_var(k(i))=1/(dwnlk_ini(k(i))+dwnSI_ini(k(i))-2*real(Phi_ini(k(i),:))*dwn_rlpt(:,k(i))+dwn_const(k(i))+1);
                %%%%%%%%%%end%%%%%%%%%%%%%%%%%%%

                %%%%%%%%%%uplink term of MMSE%%%%%%%%%%
                uplk_ch(:,k(i))=u_up_ini(k(i))*diag(H_UI(L,:))*H_IB(:,:)'*F_ini(k(i),:)';
                uplk_poly(k(i))=up_maxpower*sum(uplk_ch(:,k(i))'*uplk_ch(:,k(i)));
                uplk_ini(k(i))=Phi_ini(k(i),:)*uplk_poly(k(i))*Phi_ini(k(i),:)';

                up_rlpt(:,k(i))=sqrt(up_maxpower)*u_up_ini(k(i))*diag(H_UI(k(i),:))*H_IB(:,:)'*F_ini(k(i),:)';

                up_const(k(i))=noise_maxpower*u_up_ini(k(i))*u_up_ini(k(i))*F_ini(k(i),:)*F_ini(k(i),:)';

                upLI_ch(k(i))=u_up_ini(k(i))*F_ini(k(i),:)*H_BB(:,:)'*W_ini(:,L);
                upLI(k(i))=up_maxpower*sum(upLI_ch(k(i))*upLI_ch(k(i)));

                upSI_ch(k(i))=u_up_ini(k(i))*F_ini(k(i),:)*H_IB(:,:)*H_BI(:,:)*W_ini(:,L);
                upSI(k(i))=upSI_ch(k(i))*upSI_ch(k(i)); 

                up_aux_var(k(i))=1/(uplk_ini(k(i))+upLI(k(i))+upSI(k(i))+up_const(k(i))-2*real(Phi_ini(k(i),:)*up_rlpt(:,k(i)))+1);
                %%%%%%%%%%end%%%%%%%%%%%%%%%%%
                %%%%%%%%%%%%%%evesdroppers f(a) function%%%%%%%%%%%%
                upeve_ch(:,k(i))=diag(H_IE(:,k(i)))*H_UI(L,:)';
                upeve_poly(k(i))=up_maxpower*sum(upeve_ch(:,k(i))'*upeve_ch(:,k(i)));

                dwneve_ch(:,k(i))=diag(H_IE(:,k(i)))*H_BI(:,:)*W_ini(:,L);
                dwneve_poly(k(i))=sum(dwneve_ch(:,k(i))'*dwneve_ch(:,k(i)));

                fx_const(k(i))=log(a_ini(k(i)))+1/log(2);

                %%%%%%%%%end%%%%%%%%%%%%%%
                %%%%%%%%%constrains%%%%%%%%%%%%%%
                dwn_costri(:,k(i))=diag(H_IE(:,k(i)))*H_BI(:,:)*W_ini(:,u(i));
                dwn_cost(k(i))=dwn_costri(:,k(i))'*dwn_costri(:,k(i));
                dwn(k(i))=Phi(k(i),:)*dwn_cost(k(i))*Phi_ini(k(i),:)';
                dwn_ini(k(i))=Phi_ini(k(i),:)*dwn_cost(k(i))*Phi_ini(k(i),:)';

                up_constri(:,k(i))=diag(H_IE(:,k(i)))*H_UI(u(i),:)';
                up_cons(k(i))=up_maxpower*up_constri(:,k(i))'*up_constri(:,k(i));
                up(k(i))=Phi(u(i),:)*dwn_cost(k(i))*Phi_ini(u(i),:)';
                up_ini(k(i))=Phi_ini(u(i),:)*dwn_cost(k(i))*Phi_ini(u(i),:)';

                constrain(k(i))=dwn(k(i))+up(k(i))+noise_maxpower;
                constrain_ini(k(i))=dwn_ini(k(i))+up_ini(k(i))+noise_maxpower;

                final_constra(k(i))=2*real(constrain(k(i)))-constrain_ini(k(i));
                
                %%%%%%%%%end%%%%%%%%%%%%%%%
                finalcons(k(i))=log(abs(dwn_aux_var(k(i))))+log(abs(up_aux_var(k(i))))+2-dwn_aux_var(k(i))*dwn_const(k(i))-up_aux_var(k(i))*(up_const(k(i))+upLI(k(i))+upSI(k(i)));

                A_matrix(k(i))=dwn_aux_var(k(i))*(dwnlk_poly(k(i))+dwnSI_poly(k(i)))+up_aux_var(k(i))*uplk_poly(k(i));
                
                B_matrix(:,k(i))=dwn_aux_var(k(i))*dwn_rlpt(:,k(i))+up_aux_var(k(i))*up_rlpt(:,k(i));

                POLY(k(i))=-Phi(k(i),:)*real(A_matrix(k(i)))*Phi(k(i),:)'+2*real(Phi(k(i),:)* B_matrix(:,k(i)))+real(finalcons(k(i))+fx_const(k(i)))+elta(k(i));

                %constrai_Phi(k(i))=pow_abs(Phi_innerv(k(i),:),2)-2*real(Phi(k(i),:)*Phi_innerv(k(i),:)');
            end
         end
    end

maximize sum(a.*POLY)-scaler2*sum(sum(z))

subject to
    k=1:1:K;
    u=K:-1:1;
  for i=1:length(k)
     if k(i)==1||u(i)==1
        elta(k(i))<= log(deta(k(i)));
        deta(k(i))<=real(final_constra(k(i)));
        for m=1:M
            pow_abs(Phi(k(i),m),2) <= x(k(i),m)+z(k(i),m);
            pow_abs(Phi_innerv(k(i),m),2)-2.*real(Phi(k(i),m)'.*Phi_innerv(k(i),m))<= z(k(i),M+m)-x(k(i),m);
            x(k(i),m)+x(u(i),m)==1;
        end
            x(k(i),:)>=0;
            z(k(i),:)>=0;
     end
  end

cvx_end

     if cvx_status(1)=='S' || cvx_status(3)=='a'
    Phi_innerv=Phi;
    %gamma=0.8;
    %a=[scaler2+step,scaler_max];
    b=[scaler2+step,scaler_max];
    %b=[scaler2*gamma,scaler_max];
    %obj(temp+1)=-scaler1*sum(epselo)+sum(SINR_residual);
    %scaler1=min(a);
    %scaler1=min(a);
    scaler2=min(b);
    Phi_total(:,:,temp+1)=Phi;
    %%%stop criterion%%%
    stop(temp)=norm(Phi_total(:,:,temp+1)-Phi_total(:,:,temp),2);
    stop_1(temp)=sum(sum(z));
    %stop_2(temp)=sum(PT);
        if stop_1(temp)<=0.001 && stop(temp)<=0.001
             break;
        end
    end

end
if temp<50
break;
end

end

if cvx_status(1)==‘S’ || cvx_status(3)==‘a’
flag=1;
Phi_opt=Phi;
else
flag=0;
Phi_opt=ones(K,M);
end
end

That error message is suggestive of some kind of screwed up CVX installation or corrupted session.

What is the result of cvx_version. If it is CVX 3.0beta, do not use it, and follow the instructions at CVX 3.0beta is riddled with bugs, which are very unlikely to ever be fixed. Use the latest build of CVX 2.2

Otherwise, try a new MATLAB session.

If that doesn’t work try reinstalling CVX 2.2 in a new MATLAB session.

If that doesn’t work try rebooting.

If that doesn’t work, I’m out of ideas.

Truly thank you! I’ll try to fix it.