Error: Expressions in objective functions must be real


H and W are positive semidefinite matrix.
I don’t understand why I am getting these errors.
Can anyone help me?
Error using cvxprob/newobj
Expressions in objective functions must be real.

Error in maximize (line 21)
newobj( prob, ‘maximize’, x );

Error in sum_rate (line 56)
How can I handle this problem?

The roundoff level imaginary term cab be eliminated by

BTW, the statement W >= 0 is redundant, because W was already declared to be semidefinite.

In the future, please copy and paste code using preformatted text icon, rather than posting an image of the code. That allows readers to copy and paste the code into their own MATLAB session.

@Mark_L_Stone Thank you for your answer
Given that both matrices are in the form A*(A_hermitian), by using real(), will I not lose my information in the objective function?

my code:

cvx_begin sdp
    variable W(N,N) complex semidefinite
    subject to
      for i = 1:N
         trace(B(:,:,i)*W) == 1

No. But ultimately it is your problem, not mine. So you have to decide if it suits your purpose.

I corrected minimize to maximize in my preceding post.

1 Like

Hi, jangalok. The trace of matrix H*W is generally a complex value; therefore, you must clarify which part you need to maximize (real, imaginary, or modulo).