The error of {real affine} ./ {real affine}

clear
clc

num_bits=100000;
num_itera=20; 
W=1.25e6;
N=10^(-174/10);
omega_c=1;
omega_d=1;

P_0=100; 
Rc_min=10;
Rd_min=10;
Pc_max=250;
Pd_max=250;

err=10^(-6);
arf_ck=0.4;
arf_dk=0.5;
P_ck=10^(-4);
P_dk=10^(-5);

c_0=10^(-2);
n=4;
xi_cb=(abs(sqrt(0.5)*(exprnd(1,1,num_bits)+1i*exprnd(1,1,num_bits)))).^2;
xi_dd=(abs(sqrt(0.5)*(exprnd(1,1,num_bits)+1i*exprnd(1,1,num_bits)))).^2;
beta_cb=(abs(sqrt(0.5)*(lognrnd(0,10^0.8,1,num_bits)+1i*lognrnd(0,10^0.8,1,num_bits)))).^2;
beta_dd=(abs(sqrt(0.5)*(lognrnd(0,10^0.8,1,num_bits)+1i*lognrnd(0,10^0.8,1,num_bits)))).^2;
d_cb=80;
d_dd=90;
g_cb=c_0*xi_cb.*beta_cb*d_cb^(-n);
g_dd=c_0*xi_dd.*beta_dd*d_dd^(-n);
g_cb=mean(g_cb(:));
g_dd=mean(g_dd(:));

%******************************************************%

for k=1:1:num_itera
    lambda(k)=(omega_c*arf_ck*W*log2(1+P_ck*g_cb/(arf_ck*N*W))+omega_d*arf_dk*W*log2(1+P_dk*g_dd/(arf_dk*N*W)))/(P_ck+P_dk+2*P_0);
     cvx_begin
     variables arf_c arf_d P_c P_d
     maximize 1/log(2)*(omega_c*arf_c*W*log(1+P_c*g_cb/(arf_c*N*W))+omega_d*arf_d*W*log(1+P_d*g_dd/(arf_d*N*W)))-lambda(k)*(P_c+P_d+2*P_0)
      subject to      
        arf_c+arf_d<=1;
        arf_c*W*log2(1+P_c*g_cb/arf_c*N*W)>=Rc_min;
        arf_d*W*log2(1+P_d*g_dd/arf_d*N*W)>=Rd_min;
        P_c<=Pc_max;
        P_d<=Pd_max;
        P_c>=0;
        P_d>=0;
        arf_c>=0;
        arf_d>=0;
      cvx_end
   if abs(omega_c*arf_c*W*log2(1+P_c*g_cb/(arf_c*N*W))+omega_d*arf_d*W*log2(1+P_d*g_dd/(arf_d*N*W))-lambda(k)*(P_c+P_d+2*P_0))<err
       break
   else 
       arf_ck=arf_c
       arf_dk=arf_d
       P_ck=P_c
       P_dk=P_d
   end
end

above all is my code and the error disciplined as:Cannot perform the operation: {real affine} ./ {real affine}.I have do it for some days and remain this problem.I need help,thanks

Your code has several expressions of the form
x*log2(1+y/x)
which can be reformulated as
-rel_entr(x,x+y)/log(2)

The extra stuff in the denominator can be absorbed into the y.

I recommend use of CVX 2.2 with Mosek 9.x if available to you; otherwise follow the instructions at CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions .

Note: This is the most common reformulation in this forum. This is the 2nd one today.

Thank you, Mark. I have changed my code as your suggestion, and the current optimization function is follow:
1/log(2)(omega_cW*(-rel_entr(arf_c,arf_c+P_cg_cb/(NW)))+omega_dW(-rel_entr(arf_d,arf_d+P_dg_dd/(NW))))-lambda(k)(P_c+P_d+2P_0)
But something else is now happening, when the code is run, some other errors were made, such as
Disciplined convex programming error:
Illegal operation: {concave} - {complex affine}
or
Disciplined convex programming error:
Cannot perform the operation: {invalid} .* {real affine}

Look at the complex affine expression? Why do you have complex numbers? Should you?

Invalid probably happens in 2nd or later outer iteration (value of k) when a previous CVX problem was not successfully solved, and therefore optimal value from the previous iteration was NaN.

The input numbers to your fist iteration might be horrible, and then perhaps get worse. Your crude Successive Convex Approximation, which does not use line search or trust region for safeguarding, may not converge to anything, let alone a local or global optimum of your original problem. You may be better off using a non-convex nonlinear optimizer under YALMIP. And you still need to improve the scaling of input data.

Thank you for your advice. It is very useful to me.