Cannot maximize a(n) complex affine expression

Recently , I find this problem when I do a simulation. And I don’t know how to do for the error. The CVX function code is following:
cvx_begin sdp
variable B((MM),(MM))
variable t(NN*(NN-1)/2,1)

  dual variables P{NN*(NN-1)/2}
  dual variable Q
 subject to

Result on matlab give:
??? Error using ==> maximize at 36
Disciplined convex programming error:
Cannot maximize a(n) complex affine expression.

Error in ==> mutual at 145

where Ba and Ca are known matrices, xk is a matrix which change with iterations.
I have a limited knowledge about CVX. Thanks for your attention.

The error message is saying that CCC is complex—that is, it has both a real and an imaginary part. It is ill-posed to try and maximize or minimize a complex expression: after all, what does it mean to say x\leq y, if x and y are complex?

Now, sometimes you intend for your expression to be real, but due to roundoff errors, there remains a small imaginary residual. If that’s the case here, you can just do maximize(real(CCC)).

On the other hand, if you’re trying to maximize the magnitude of CCC—well, CVX can’t do that, because you can’t maximize a convex expression in CVX, and complex magnitude is convex.

It is also possible (because I’ve seen this kind of mistake before) that you simply need to think more about what you are trying to do with your model; that CCC isn’t really the correct objective.