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 = p*h/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_a*log(bar_gama)/log(2);
for i=1:5
cvx_begin
variable q
expression Rk
minimize alpha*(power(2,q))

*lambda_k*D-A

*Rk*

subject to

Rk = Balpha*(bar_a*(q+log(h/N_0)/log(2)+log(bar_gama2)/log(2)-log((power(2,q))

subject to

Rk = B

*(h/N_0)+bar_gama2+1))/log(2)+bar_b);*

% (power(2,q)) >= 0;

(power(2,q)) <= P_max;

(Dlambda_k

% (power(2,q)) >= 0;

(power(2,q)) <= P_max;

(D

*f_VEC)/(T_pra*f_VEC-C*lambda_k) <= Rk;

cvx_end

%%

gama1 = (power(2,q))

*h/N_0;*

gama = gama1bar_gama2/(gama1+bar_gama2+1);

gama = gama1

```
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;

![image|429x52](upload://9k4sDTIPCmZKPvlmExSTMx7jsCh.png