Illegal operation: {invalid} + {mixed real affine/constant}

Hi, Professor
I got a problem when I run my code, the matlab reported: Illegal operation: {invalid} + {mixed real affine/constant}. Maybe something wrong in routine x_tilde == Fx0 + Hu; But I don’t know why. I think it is convex.
I want to attach my code. But I don’t find any button to upload .m files. How to upload my files? Because it is a little long. I think it is not a good way to copy them and paste them in text here directly.

Look at the term which is:“invalid” and try to figure out why it is invalid. If the invalid term is comprised of individual (additive or multiplicative) terms, determine which of these are invalid and why.

Actually, the matrix F is a strictly lower triangular matrix (constant matrix),and x0 is also an constant vector. The term F*x0 is constant which I think it is convex when it was added to an affine expression. So I don’t know why it said it is invalid. Furthermore, in the first several iteration, there are no error reports and the optimization problem was run successfully. But it always was terminated in certain iteration(BTW, implemented in receding horizon optimization way). So I am confuse about it.

Invalid does not mean non-convex. it could be due to NaN being used in a calculation.

Have you checked the solution status on every iteration, and perhaps apply isnan to test all results you will use in the next iteration? Perhaps on some iteration, CVX is not successfully solving the problem, thereby resulting in NaN in CVX variables which perhaps are being used in the next iteration, making the result of such calculation “invalid”.

Thank you Professor Mark, you’re right. When the error happened, it always showed a Nan solution in the last iteration. So this is because the last optimization problem in last iteration is unfeasible, isn’t it?

That is a possibility, but I;m not sure if it is the only possibility. You should look at cvx_status, which will indicate whether the problem is infeasible, or perhaps has failed for some other reason (solver difficulty).

BTW, I’m not a professor. I’m just a random Joe Blow (as we say in the U.S.) who happens to have read CVX’s documentation.http://cvxr.com/cvx/doc/ and Why isn’t CVX accepting my model? READ THIS FIRST! and used CVX a bit.

I am sorry to bother you and appreciate for your help.