Function
Purpose
Function representation for MPT
Syntax
F = Function(@fun, data)
F = Function(@fun)
F = Function([],struct('p',2))
Description
The Function class represents functions handles that are associated to sets in MPT. The class
combines the function_handle with changeable parameters which allows
specifications of very general functions. When constructing the Function object, the
correctness of the given function is not tested. It is up to the user to provide correct mapping, or test
it via feval method for ConvexSet class.
Domain of the function is specified by the set it is associated to. If the point lies outside of the domain,
an error is thrown.
The range of the function is not known at the time of the construction of the Function object. It
can be determined after evaluation of the related function for given point.
User can associate any data with the function, including parameters of the function, under the Data
field. These data can be modified anytime after the construction of the object.
Input Arguments
Handle |
A function_handle that represents the function. It can be an anonymous function, e.g.
that corresponds to syntax or it can be a link to another file that
evaluates the expression, i.e. @file. Both of the expressions are fine as long as the given
handle can be evaluated at the time of the construction.
If more arguments (or parameters) are present in the function, the arguments are separated with a comma,
e.g. corresponds to . For more info about
constructing handles see help for function_handle class.
Class: function_handle
|
Data |
Any data related to the function. It can be function parameters, variable bounds, domain, range,
measured data, symbolic representation, etc. The data can be changed after construction of the
Function object. |
Output Arguments
F |
Function object.
Class: Function
|
Example(s)
Example
1
Construct empty Function
F=Function
Empty Function
Construct an 5x1 array of empty Function objects F(5,1) = Function
Array of 5 Functions.
Example
2
Construct anonymous function
F = Function(@(x,y) (x-y)/(x^2+y^2)^0.5)
Function: @(x,y)(x-y)/(x^2+y^2)^0.5
Example
3
Construct anonymous function
with parameters
and
. Firstly, construct empty Function object and put the parameter values inside the Data field F = Function([],struct('a',10.4,'b',-0.56))
Empty Function
Secondly, set the handle pointing to the parameters stored inside Data property F.setHandle(@(x) F.Data.a*sin(F.Data.b*x))
Function: @(x)F.Data.a*sin(F.Data.b*x)
The values of the parameters
,
can be modified after construction of the object.
The Function object will then take the new values of the parameters. F.Data.a = 12.78; F.Data.b = -0.93
Function: @(x)F.Data.a*sin(F.Data.b*x)
Example
4
For functions arrays you must correctly refer to the appropriate index of the function data Allocate an array of Function objects F(2,1) = Function
Array of 2 Functions.
Assign the data F(1).Data = struct('a',-1,'b',2);
F(1).setHandle(@(x) F(1).Data.a*sin(F(1).Data.b*x));
F(2).Data = struct('a',-3,'b',4);
F(2).setHandle(@(x) F(2).Data.a*sin(F(2).Data.b*x));
See Also
afffunction, quadfunction, sethandle
© 2010-2013 Martin Herceg: ETH Zurich, herceg@control.ee.ethz.ch