Hello everyone,

It is been i while that i can’t solve my problem. The code below is for an optimization including the cost function of a log function.

As you can see in the code, i used the entr function as sugggested for solving this kind of problem.

Please feel free to give me advise/suggestion concerning my following erroned code.

Thanks in advance.

Matlab code:

%%%%%%%%%Test Allocation secondaire%%%%%%%%%%%%%%

```
clear, clc,
M=5; %%
L=4; %%
Q_M=1; %%
Q=4; %%
H=randn(M,L); %%
Ki=randn(M,L); %%
sigma2=1; %%noise power
d_min=2*sqrt(3/(Q*(Q-1)));%
%%Choose a canal
m=randperm(M);
m=m(1);
%%Optimization problem
cvx_begin
variable q(L) nonnegative
fc=0;
for l=1:L
sinr=2*Ki(m,l)^2/(sigma2+abs(H(m,L))^2*q(l)); %sinr
P_es=2*(Q-1)/Q*erfc(sqrt((3/(Q^2-1))*sinr));
X2_ml=sigma2 + P_es*(Ki(m,l)^2)*d_min^2;
%fc=fc+log2(1+(abs(H(m,l))^2*q(l))/X2_ml);
fc=fc + (inv_pos(X2_ml + H(m,l)^2*q(l))*rel_entr(H(m,l)^2*q(l)+ X2_ml, X2_ml))
end
maximize(fc);
%subject to
%norm(q,1) <= Q_M
cvx_end
```