Hello

My problem here is the code

When writing this code I encounter the following error

Undefined function or method ‘log2’ for input arguments of type ‘cvx’.

Code is written by me as follows:

clc

clear all

close all

%%

N = 1000; % number of bits or symbols

h =1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % Rayleigh channel

H = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)];

%%

p1=2;

p2=10;

pc=1;

alpha=10;

NT1=2;

NT2=2;

NR=2;

B=180*(10^3);

F=3;

N0=-174;

sigma=F*B*N0;

i=ones(1,N);

%%

k21_0=randn(1,N);

k22_0=randn(1,N);

Q1=(p1./(sum(diag(h))).^2)*(H*ctranspose(H)*h*ctranspose(h));

R1=@(k21,k22) log2(1+(p1*(sum(diag(h))).^2)/(sigma+(k21+k22).*h*ctranspose(h)));

R12=@(k22) log2(abs(i+(sigma.*i+H.*k22*ctranspose(H)).^(-1).*Q1));

R2=@(k21,k22) log2(abs(i+inv(sigma).*H.*(k21+k22)*ctranspose(H)+inv(sigma)*Q1))-R12;

Pint=@(R1) ((p1.*(norm(h)).^2)./(2.^((R1))-1))-sigma;
R=log2(1+(p1*(norm(h))^2/sigma));

N=@(k21) log2(abs(i+k21.*h*ctranspose(h)+(sigma*i+Q1).^(-1)));

D=@(k21) alpha.*sum(diag(k21))+pc;

q=N(k21_0)/D(k21_0);

%%

cvx_begin

variables k21

N=log2(abs(i+k21.*h*ctranspose(h)+(sigma*i+Q1).^(-1)));

D=alpha.*sum(diag(k21))+pc;

EE=N-q.*D;
minimize N
subject to
R*(k21)>=R

R12>=R

trace(k21)<=p2

cvx_end

Please help me solve this problem

Thanks