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

First, look at CVX status and see why it failed. Numerical problems, or uinbounded, or infeasible? Mosek output provides good diagnostic information, including warning messages about very small or large magnitude numbers in input data.

Please read NaN——Status: Infeasible Optimal value (cvx-optval): - Inf - #2 by Mark_L_Stone