# integer

Tags:

Updated:

integer is used to constrain a variable to be integer.

## Syntax

F = integer(x)


## Examples

Setting up a integer linear program can be done as

x = intvar(n,1);
optimize([A*x<=b],c'*x)


or

x = sdpvar(n,1);
optimize([A*x<=b, integer(x)],c'*x)


The integrality constraint is imposed on the involved variables, not the actual expression. Hence, the following two constraints are equivalent.

F = integer(x);
F = integer(pi+sqrt(2)*x);