How to write to find a non-zero solution x(n) in CVX


If my optimization problem needs to find a non-zero vector solution x(n), how to write it in CVX? Thank you so much.


For example, in the following problem, how to write z~=0?

You will have to pick a tolerance for what constitutes non-zero. Because the constraint is non-convex, you will need to introduce binary variables and use Big M.

YALMiP has a function, nnz . The web page shows the Big M formulation YALMIP uses to handle nnz. This formulation can also be used in CVX.