The code can run,however,there are two warnings about non-empty cvx problem, and Function single has the same name as a MATLAB builtin

function [P_Tq]=finall_op4_Pq_P_Tq(P_q)
load('GwwOA_algorithm_2','P_q')
bd=50
AXX3=zeros(1,bd);
rho_k= 0.001:0.001:0.015
rk=length(rho_k)
for bf=1:rk
    for f=1:bd
        hat_p_up=P_q
        %hat_p_up=0.00015
        %OP4
        %declare
        K=4;
        N=4;
        L=5;
        nois_var_hk_2pow=0.1*(L^(-2.5));%W,0.1*(L^(-2.5)),if this unit is dbm
        nois_var_ak_2pow=[1.0000e-10 1.0000e-10 1.0000e-10 1.0000e-10 ];
        nois_var_dk_2pow=[1.0000e-08 1.0000e-08 1.0000e-08 1.0000e-08 ];
        bar_r=[10 10 10 10];
        P_T=10
        %channel build
        hh_1=normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])+1i*normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])
        h_1=sqrt((real(hh_1)).^2+(imag(hh_1)).^2)
        hh_2=normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])+1i*normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])
        h_2=sqrt((real(hh_2)).^2+(imag(hh_2)).^2)
        hh_3=normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])+1i*normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])
        h_3=sqrt((real(hh_3)).^2+(imag(hh_3)).^2)
        hh_4=normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])+1i*normrnd( 0,sqrt(0.1*(L^(-2.5))) ,[4,1])
        h_4=sqrt((real(hh_4)).^2+(imag(hh_4)).^2)
        h_kk=cat(2,h_1 ,h_2 ,h_3, h_4)
        for n=1:4
            h_k{n}=h_kk(1:4 , n);
            n=n+1;
        end
        %==========================
        cvx_begin
        variable FNNK_up(N,N,K) semidefinite;%c7
        %==========================
        Fkk_up=cat(2,FNNK_up);
        up=0
        for o_up=1:4
            Fk_up{o_up}=Fkk_up(1:4,o_up+3*up:4*o_up)
            up=up+1;
        end
        tr_ace_up=0
        for t=1:K
            tr_ace_up=tr_ace_up+trace(Fk_up{t})
        end
        %====================================
        %object function
        minimize( tr_ace_up )
        %====================================
        %Constraint
        subject to
        %===================================================
        %c5
        c5_left_hand_up = 0;
        for k = 1:K
            sum_5_up = 0;
            for j = 1:K
                if j ~= k
                    sum_5_up = sum_5_up +  h_k{k}' * Fk_up{j} * h_k{k};
                end
            end
            c5_left_hand_up = c5_left_hand_up - sum_5_up+ (h_k{k}' * Fk_up{k} * h_k{k}*inv_pos(bar_r(1)))
            c5_right_hand_up= nois_var_ak_2pow(1)*rho_k(bf)+ nois_var_dk_2pow(1)
            real( c5_left_hand_up ) *rho_k(bf) >=   c5_right_hand_up
        end
        
        %===================================================
        %c10
        c10_left_hand_up = 0;
        sum_10_up = 0;
        for j = 1:K
            sum_10_up= sum_10_up +  h_k{k}' * Fk_up{j} * h_k{k};
        end
        c10_left_hand_up =real(c10_left_hand_up + sum_10_up+nois_var_ak_2pow(1))*(1-rho_k(bf))
        c10_right_hand_up=hat_p_up
        c10_left_hand_up>=  c10_right_hand_up
        cvx_end
        c3(f)=AXX3(f)+cvx_optval
    end
    yn=c3(~isnan(c3))
    mean_of_c3_except_outlier(bf)=mean(yn( ~Isoutlier(yn)))
    P_Tq=min(mean_of_c3_except_outlier)
end
save('finall_op4_Pq_P_Tq','P_Tq')
end

Here is my code,and it can run and calculate the value i wanted,however,there are two warning in my window,and i want to improve the code and let the warning disappear

1.Warning: A non-empty cvx problem
already exists in this scope.
It is being overwritten.

In cvxprob (line 28)
In cvx_begin (line 41)
In final_op4_Pp_P_Tp (line 38)
In GwwOA_algorithm_2 (line 22)

2.Warning: Function single has the
same name as a MATLAB builtin. We
suggest you rename the function to
avoid a potential name conflict. 
> In variable (line 90)
  In final_op4_Pp_P_Tp (line 39)
  In GwwOA_algorithm_2 (line 22) 

Can anyone help me how to improve this warning?

In variable (line 90)
In final_op4_Pp_P_Tp (line 39)
In GwwOA_algorithm_2 (line 22)

This warning,i think it means that there warning happen in this ā€œvariableā€,and this ā€œvariableā€ is in the ā€œfinal_op4_Pp_P_Tpā€ code,and the ā€œfinal_op4_Pp_P_Tpā€ is in the ā€œGwwOA_algorithm_2ā€,so i just show the ā€œfinal_op4_Pp_P_Tpā€ code in here.

1 Like
  1. You must have had cvx_begin without cvx_end and then another cvx_begin. The warning message is harmless. When that 2nd cvx_begin is issued, all CVX declarations, expressions, constraints, objective, etc.from before the 2nd cvx_begn are thrown out, i.e., overwritten. If you issue cvx_clear before the 2nd cvx_begin, everything will work out the same, but without warning message.

  2. As the warning states, uses a function name other than single.

1 Like