addFunction

Purpose

Attach function to a convex set.

Syntax

Set = addFunction(Set,F,FuncName)
Set.addFunction(Set,F,FuncName)

Description

Assign a Function object F to a convex set Set under the name FuncName. The set represent the domain of the function. The string FuncName is obligatory and is used to identify the function from the list. Multiple functions can be assigned to a set, their names must be different.

Input Arguments

Set

Any object derived from the ConvexSet class, e.g. Polyhedron, YSet, ...

Class: ConvexSet

F

Function or an array of functions to be assigned, given as objects derived form Function class.

Class: Function

FuncName

A string or an cell array of strings that represent the name of the assigned function. Every function must have an unique name.

Class: struct

Output Arguments

Set

Modified object of ConvexSet class that has a function stored under the Func property.

Class: ConvexSet

Example(s)

Example 1

Construct polyhedron ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction1.png
P = Polyhedron(1, 1)
Polyhedron in R^1 with representations:
    H-rep (redundant)   : Inequalities   1 | Equalities   0
    V-rep               : Unknown (call computeVRep() to compute)
Functions : none
Define a function over ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction2.png this set as a QuadFunction object.
F = QuadFunction(3,0,1) 
Quadratic Function: R^1 -> R^1
Assign a function F to this set P under name "f".
 P.addFunction(F,'f') 
Polyhedron in R^1 with representations:
    H-rep (redundant)   : Inequalities   1 | Equalities   0
    V-rep               : Unknown (call computeVRep() to compute)
Functions : 1 attached "f"

Example 2

Construct 2 polyhedra, ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction3.png, ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction4.png
 P1 = Polyhedron(1,1); P2 = Polyhedron(-1,-1); 
 Put the polyhedra to one array. 
 P = [P1, P2]; 
 Define function ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction5.png that we want to associate to both functions. 
 F = Function(@(x)x/(x-1)) 
Function: @(x)x/(x-1)
Add the function to each of the polyhedron in the array P and give it the name "f".
 P.addFunction(F,'f') 
Array of 2 polyhedra.

Example 3

Add two functions ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction6.png and ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction7.png to a circle ../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction8.png Define the set using YALMIP
 x = sdpvar(2,1); Set = YSet(x, [norm(x)<=1]); 
 Define the functions
 f1 = Function(@(x) sqrt(x(1)^2+x(2)^2+1)); f2 = Function(@(x) (x(1)-2)/(x(2)+3)); 
 Add these functions to the circle Set 
      
 Set.addFunction(f1, 'polynomial')
YALMIP set in dimension 2.
Functions : 1 attached "polynomial"
 Set.addFunction(f2, 'rational') 
YALMIP set in dimension 2.
Functions : 2 attached "polynomial", "rational"
Plot the functions above the set
 Set.fplot('polynomial') 

../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction_img_1.png

 Set.fplot('rational') 

../../../../../../fig/mpt/modules/geometry/sets/@ConvexSet/addfunction_img_2.png

See Also

convexset, function, quadfunction, afffunction, removefunction


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