Main Content

polyBasis

Polynomial basis functions for tunable gain surface

Description

You use basis function expansions to parameterize gain surfaces for tuning gain-scheduled controllers. polyBasis generates standard polynomial expansions in any number of scheduling variables. Use the resulting functions to create tunable gain surfaces with tunableSurface.

shapefcn = polyBasis('canonical',degree) generates a function that evaluates the powers of an input variable, x, up to degree:

shapefcn(x)=[x,x2,,xorder].

example

shapefcn = polyBasis('chebyshev',degree) generates a function that evaluates Chebyshev polynomials up to degree:

shapefcn(x)=[T1(x),,Torder(x)].

The Chebyshev polynomials are defined recursively by:

T0(x)=1;T1(x)=x;Ti+1(x)=2xTi(x)Ti1(x).

example

shapefcn = polyBasis(___,nvars) generates an nvars-dimensional polynomial expansion by taking the outer product of nvars 1-D polynomial expansions. The resulting function shapefcn takes nvars input arguments and returns a vector with (degree+1)^(nvars-1) entries. For example, for nvars = 3 and canonical polynomials,

shapefcn(x,y,z)=[xiyjzk:0i,j,korder,i+j+k>0].

Thus, to specify a bilinear function in two scheduling variables, use:

shapefcn = polyBasis('canonical',1,2);
Using the resulting function with tunableSurface defines a variable gain of the form:

K(x,y)=K0+K1x+K2y+K3xy.

Here, x and y are the normalized scheduling variables, whose values lie in the range [–1,1]. (See tunableSurface for more information.)

To specify basis functions in multiple scheduling variables where the expansions are different for each variable, use ndBasis.

example

shapefcn = polyBasis(___,varnames) specifies variable names. Use this syntax with any of the previous syntaxes to name the variables in shapefcn. Using variable names improves readability of the tunableSurface object display and of any MATLAB® code you generate using codegen.

example

Examples

collapse all

Create basis functions for a gain that varies as a cubic function of one scheduling variable.

shapefcn = polyBasis('canonical',3);

shapefcn is a handle to a function of one variable that returns an array of values corresponding to the first three powers of its input. In other words, shapefcn(x) = [x x^2 x^3]. For example, examine shapefcn(-0.2).

x = -0.2;
shapefcn(x)
ans = 1×3

   -0.2000    0.0400   -0.0080

Evaluating [x x^2 x^3] for x = -0.2 returns the same result.

[x x^2 x^3]
ans = 1×3

   -0.2000    0.0400   -0.0080

Use shapefcn as an input argument to tunableSurface to define a polynomial gain surface. This shapefcn is equivalent to using:

shapefcn = @(x) [x x^2 x^3];

Create a set of basis functions that are Chebyshev polynomials of a single variable, up to third degree.

shapefcn = polyBasis('chebyshev',3);

Create basis functions for a bilinear gain surface, [x,y,xy]. Name the variables to make the function more readable.

shapefcn = polyBasis('canonical',1,2,{'x','y'})
shapefcn = function_handle with value:
    @(x,y)utFcnBasisOuterProduct(FDATA_,x,y)

Confirm the values returned by shapefcn for a particular (x,y) pair.

x = 0.2;
y = -0.5;
shapefcn(x,y)
ans = 1×3

    0.2000   -0.5000   -0.1000

This shapefcn is equivalent to:

shapefcn = @(x,y)[x,y,x*y];

The basis functions of shapefcn are first-order in each of the two variables. To create a set of basis functions in different degrees for each variable, use ndBasis.

Input Arguments

collapse all

Degree of the polynomial expansion, specified as a positive integer.

Number of scheduling variables, specified as a positive integer.

Variable names in the generated function shapefcn, specified as a:

  • Character vector, for monovariable basis functions.

  • Cell array of character vectors, for multivariable basis functions.

If you do not specify varnames, then the variables in shapefcn are named {'x1','x2',...}.

Example: {'alpha','V'}

Output Arguments

collapse all

Polynomial expansion, specified as a function handle. shapefcn takes as input arguments the number of variables specified by nvars. The function evaluates polynomials in those variables up to the specified degree, and returns the resulting values in a vector. When you use shapefcn to create a gain surface, tunableSurface automatically generates tunable coefficients for each polynomial term in the vector.

Version History

Introduced in R2015b