What are the reasons for this situation? Can you help me

clc;clear all;close all
R = 500;
K = 1;
d_1 = 0.001;
d_2 = 0.3;
h = 10e-4;
g = 0.001;

D = 5e5;
C = 1e9;
tau = 0.5;
P_k = 0.25;
P_max = 0.5;
B = 12e3;
N_0 = 10e-19;

v_k = 25;
alpha = 1;
lambda_k = 1;
f_VEC = 8e9;
T_0 = R/v_k;
T_pra = min(T_0,tau);

A = 0;

p = 0.1;
bar_gama1 = ph/N_0;
bar_gama2 = P_k
bar_gama = bar_gama1*bar_gama2/(bar_gama1+bar_gama2+1);

bar_a = bar_gama/(1+bar_gama);
bar_b = log(1+bar_gama)/log(2)-bar_alog(bar_gama)/log(2);
for i=1:5
variable q
expression Rk
minimize alpha
subject to
Rk = B
% (power(2,q)) >= 0;
(power(2,q)) <= P_max;
lambda_kf_VEC)/(T_praf_VEC-C*lambda_k) <= Rk;
gama1 = (power(2,q))h/N_0;
gama = gama1

 a = gama/(1+gama);
 b = log(1+gama)/log(2)-a*log(gama)/log(2); 
 bar_a = a;
  bar_b = b;


 A = alpha*2^q*lambda_k*D/Rk;
 AA(i) = A; 


hold on;

In one iteration, the problem is infeasible. So the CVX variable value after cvx_end id NaN. Your program uses this value, equal to NaN in a CVX expression in the next iteration. That is not allowed.

You can search my previous posts on this forum to see my warnings about the perils of SCA.

Is it a discussion about this topic"The optimization process is unbounded and then solved when using SCA"?

I have many posts. Crude, unsafeguarded (no line search or trust region) SCA is very unreliable, and often fails when applied to new problems. It may not converge to anything, and if it does, it may not be a global or even local optimum. You may be better off using an existing non-convex solver (for instance, under YALMIP) than writing your own SCA.