contains

Purpose

Test if the point is contained inside convex set YSet.

Syntax

ts = S.contains(x)
ts = contains(S, x)

Description

Returns true if ../../../../../../fig/mpt/modules/geometry/sets/@YSet/contains1.png and false otherwise.

Input Arguments

S

A convex set described as YSet object.

Class: YSet

x

A point given as vector. Note that for YSet with symmetric matrix variable, the point x must be given as vector with symmetric terms.

Class: double

Output Arguments

ts

True if the point x is contained inside YSet

Class: logical

Allowed values:

  • true
  • false

Example(s)

Example 1

Create two sets: polytope P and circle C in 2D.
x = sdpvar(2,1);

F1 = [ [1 -2;-0.4 1;0.6 -5]*x<=[1;1.2;1.7] ];

F2 = [ 0.3*x'*x-4*x(1)+2*x(2)<=0.1 ];

P = YSet(x,F1);

C = YSet(x,F2);
It is obvious that the point x=[0;0] must lie inside both sets. Define the point v and the array S. 
v = [0;0];

S = [P;C];
 Check if the point is contained in both sets. 
 S.contains(v) 
ans =

     1
     1

We can plot the sets and the point x.
 S.plot; hold on; text(v(1),v(2),'\bf x'); 
Plotting...
23 of 40

../../../../../../fig/mpt/modules/geometry/sets/@YSet/contains_img_1.png

For instance, the point z=[5;-5] lies only in the set C.
 z = [5;-5]; 

 S.contains(z) 
ans =

     0
     1

See Also

yset


© 2010-2013 Martin Herceg: ETH Zurich, herceg@control.ee.ethz.ch