# ismember

Tags:

Updated:

ismember is used to constrain an sdpvar object to be selected from a set of constants, or to be inside MPT polytopes.

### Syntax

F = ismember(x,Y)


### Examples

To constrain a scalar sdpvar variable to take a value from a finite set, ismember can be used.

sdpvar x
F = ismember(x,[1 2 3 4]);


Of course, this can also be obtained with a standard integer variable

intvar x
F = [1 <= x <=4];


or an integrality constraint.

sdpvar x
F = [integer(x), 1 <= x <= 4];


The functionality is more useful when the set is more complicated.

sdpvar x
F = ismember(x,[1 pi 12 -8]);


The function can also be used together with the polytope object in MPT to constrain a variable to be inside at least one of several polytopes.

x = sdpvar(3,1);
P1 = polytope(randn(10,3),rand(10,1));
P2 = polytope(randn(10,3),rand(10,1));
F = ismember(x,[P1 P2]);