The following error occurs:Disciplined convex programming error: Illegal operation: {real affine} - {invalid}

My guess: on an iteration, CVX did not solve a problem to optimality. Hence, the values populating the CVX variables after cvx_end for that iteration are NaN. When these values are used as input data in the next iteration, CVX will consider them invalid.

Is NaN*x^2 a convex expression with respect to a CVX variable x.? You can’t say it is. Neither can CVX. CVX can’t even determine what to do with NaN*x, for which the sign of NaN is irrelevant. Apart from convexity, what problem could it provide to the solver even if there were no convexity restriction?

Successive Convex Approximation (SCA) can be quite unreliable. See my many posts on this forum.