In my optimization problem, one of the constraints is as follows

imag$(hg)==0$; that is the imaginary part of hg is set to 0.

here, h is a complex vector (constant) of size (1 x 4) and g is the variable.

My matlab code is:

y=randn(1,1);

cvx_begin gp quiet

variable g(4,1) complex;

variables t(1), x(1);

maximize(-----)

subject to

imag(hg)==0;

1/2((t-1)/y+yx^2)<=hg

cvx_end

The solver shows an error! How do I express these constraints in GP mode?

The error message is as follows:

Error using &

NaN’s cannot be converted to logicals.

Error in cvx/cvx_vexity (line 38)

v( any( imag( x.basis_ ), 1 ) & v ) = NaN;

Error in cvx/mtimes (line 297)

v = cvx_vexity( z );

Error in matGP (line 74)

imag(h*g) == 0;