What's wrong with cvx?

My code is as follow:
%% Parameters
para = para_init();
theta_degree = -90:90;
belta = sin(pi/para.omiga)(sqrt(para.gammapara.sigma_k));
A =zeros(para.M,para.M);
B =zeros(para.M,para.M);
%% Monte Carlo Simulation
for n=1:MonteCarlo
s = exp(-j*( exp(j*( exp(j*(pi/4)) )) ));
for k=1:(para.K)
variable Ak(para.M,para.M) complex
variable x(para.M,1) complex
minimize( trace_inv(A) );
subject to
[Ak x;…
x’ 1]==hermitian_semidefinite(para.M+1);
real(h’xs)*sin(pi/para.omiga) - abs( imag(h’xs) )*cos(pi/para.omiga) >= belta;

the output is as follow:
Disciplined convex programming error:
Illegal operation: {invalid} + {complex affine}

Untitled2 (line 19) is wrong

Can you help me?Thank you!

Your code is not reproducible, para_init is missing, and please use a markdown format. As for the error, I think it might be caused by the bad data A from the previous iteration, which might be infeasible or failed.

Elaborating on @jackfsuia 's answer, if one iteration of CVX fails due to being infeasible or solver numerical difficulty, the variable values are populated with NaN, which are then fed in as input data to the next iteration. CVX considers NaN input data to be invalid, hence the error message.

You should ask not what is wrong with CVX, but what is wrong with crude, unsafeguarded SCA.

pls check the cvx_status of every iteration (you have MonteCarlo*para.K iterations in total), if any of them is failed or infeasible, it will output the wrong A, which will cause the error to your next iteration of CVX since A is also the input data of your next iteration.

If it turns out to be failed or infeasible, I don’t know what to do in general. Sometimes it took me months.

Look at the solver and CVX output for each CVX problem instance being solved.

And unsafeguarded SCA is a very perilous algorithm, which might not converge to anything, let alone a global or even local optimum of the original problem.

Yes, Successive Convex Approximation.