Cvx&Matlab: declaration of variables: mixed integer linear programming

I try to construct and solve a mixed integer problem.

This is how I made the declaration of the variables:

variables x1 x2 x3;
variable x4 integer;
x = [x1,x2,x3,x4];

If the mixed integer problem has many variables, this method is long-winded. Is there an efficient way to declare many variables for example with a for-loop?

Suppose the vector I contains the indices of the variables which are to be integers. Then you could do something like this:

m = length(I);
variable x(n);
variable y(m) integer;
x(I) == y;

Thank you :slight_smile: