How to describe this problem

image description

The first figure is my formulation, where all matrices are Hermitian.

The second figure is my code about this problem, once i try to compile it in the matlab, there is an error:Invalid constraint: {complex affine} <= {real constant}, but the left side and right side are all real value from mathmatical perspective. What can i do to make the code work well ?

Please stop using images here. Learn to use the LaTeX and Markdown support instead. And please use more specific titles! “How to describe this problem” doesn’t help anyone know whether this is a question they might find interesting.

If you are sure the quantity on the left should be real, then it’s possible that roundoff error is causing small imaginary residuals to show up. So just wrap the left-hand side in a real() function and you should be fine.

But again, make sure that the left-hand result is supposed to be real. If any of the quantities R, X, etc. are complex, then the quantity as you’ve written it should be complex.