# How to handle trace with CVX? Error: Only scalar quadratic forms can be specified in CVX

Hello dears,
If someone has an idea about how to handle this.

``````N = 3; % number of transmitter antenna
theta_l = 10;
a_theta_l = exp(1j*2*pi*0.5*(0:N-1)'*sin(theta_l));%steer vector
z_theta = N*eye(N)-(a_theta_l*ctranspose(a_theta_l));
phi_theta_l = phi_theta_l(theta_l);

cvx_begin
variable w(N,N) complex
minimize(norm(phi_theta_l + trace(z_theta*w*w'))^2)
cvx_end
``````

phi_theta_l is a constant.

Welcome to the forum!

`w*w'` is non-convex… But even if it were real, taking the `norm` of a non-affine argument would not be allowed. I’m not saying for sure that the overall objective function is non-convex, but will assume it is not unless you prove otherwise.

Note: If `z_theta` is Hermitian semidefinite, `trace(z_theta*w*w')` can be reformulated as `square_pos(norm(sqrtm(z_theta)*w,'fro'))`, but then you couldn’t take the norm of that (plus plhi_theta_1) because it is not affine.

Yes z_theta is is Hermitian semidefinite. Thank you very much.

Without the `phi_theta_1` term, you could use `square_pos(norm(sqrtm(z_theta)*w,'fro'))`
or equivalently (in terms of argmin)
`(norm(sqrtm(z_theta)*w,'fro'))`
for the object5ive function.

Is `phi_theta_1 >= 0` ?

Maybe you can change the objective a little into something acceptable to CVX?

Yes phi_theta_1 >=0.

I believe you can reformulate the objective as
`minimize(phi_theta_l^2 + 2*phi_theta_1*square_pos(norm(sqrtm(z_theta)*w,'fro')) + pow_pos(norm(sqrtm(z_theta)*w,'fro'),4))`

You should check to make sure I didn’t make any mistakes.

Edit: I added a missing parenthesis to close `minimize(`

Yes i think you’re correct. Thank you very much Sir.