Hello Everyone,

When I run my code in Matlab, I get the error message “your objective function is not a scalar”. I am new to CVX, please help me to solve this problem. Below is my Matlab code:

```
clc;
M = 2;
K = 10;
N = 8;
B_total = 20 *10^6; % in hertz
P_total = 100; % in watt
QoS_req = 10*10.^6; %in bps
for i = 1:M
b_initial(i) = 2;
for j = 1:K;
w_initial(:,:,i,j) = complex(randn(N,1),randn(N,1));
h(:,:,i,j) = complex(randn(N,1),randn(N,1));
SINR_initial(i,j) = 1024;
y_initial(i,j) = 1;
end
end
cvx_begin
a= 0;
variables b(M) x(M,K) y(M,K) SINR(M,K);
variable w(N,1,M,K) complex;
whos
maximize (x)
subject to
for i = 1:M
H =[];
c=[];
for j = 1:K
a = a + pow_pos(norm(w(:,1,i,j),2),2);
log(1+SINR(i,j))./log(2) >= y(i,j);
2*(b(i)+y(i,j))*(b_initial(i)+y_initial(i,j))-(b_initial(i)+y_initial(i,j)).^2 >= 2*x(i,j) +b(i).^2+y(i,j).^2;
H = h(:,:,i,j)*h(:,:,i,j)';
for l = 1:K
if l~=j
c = c+ ((h(:,:,i,j)'*w(:,1,i,l))*(h(:,:,i,j)'*w(:,1,i,l))');
end
end
log(1+SINR(i,j))./log(2) >= (QoS_req)*inv_pos(b(i));
c+b(i)*10^(-11) <= ((2*w(:,1,i,j)'*H*w_initial(:,1,i,j))./(SINR_initial(i,j)) - SINR(i,j)*((w_initial(:,1,i,j)'*H*w_initial(:,1,i,j))./(SINR_initial(i,j)).^2));
end
end
sum(b) <= B_total;
a <= P_total;
cvx_end
```

Thanking you for your help.