# 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
g/N_0;
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
cvx_begin
variable q
expression Rk
minimize alpha
(power(2,q))lambda_kD-ARk
subject to
Rk = B
alpha*(bar_a*(q+log(h/N_0)/log(2)+log(bar_gama2)/log(2)-log((power(2,q))(h/N_0)+bar_gama2+1))/log(2)+bar_b);
% (power(2,q)) >= 0;
(power(2,q)) <= P_max;
(D
lambda_kf_VEC)/(T_praf_VEC-C*lambda_k) <= Rk;
cvx_end
%%
gama1 = (power(2,q))h/N_0;
gama = gama1
bar_gama2/(gama1+bar_gama2+1);

`````` bar_gama1=gama1;
bar_gama=gama;
%%
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;
``````

end

figure,plot(1:5,AA);
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.