Basis functions for tunable gain surface

You use basis function expansions to parameterize gain surfaces for tuning gain-scheduled controllers, with the tunableSurface command. The complexity of such expansions grows quickly when you have multiple scheduling variables. Use ndBasis to build N-dimensional expansions from low-dimensional expansions. ndBasis is analogous to ndgrid in the way it spatially replicates the expansions along each dimension.


shapefcn = ndBasis(F1,F2)
shapefcn = ndBasis(F1,F2,...,FN)



shapefcn = ndBasis(F1,F2) forms the outer (tensor) product of two basis function expansions. Each basis function expansion is a function that returns a vector of expansion terms, such as returned by polyBasis. If F1(x1)=[F1,1(x1),F1,2(x1),,F1,i(x1)] and F2(x2)=[F2,1(x2),F2,2(x2),,F2,i(x2)], then shapefcn is a vector of terms of the form:


The terms are listed in a column-oriented fashion, with i varying first, then j.

shapefcn = ndBasis(F1,F2,...,FN) forms the outer product of three or more basis function expansions. The terms in the vector returned by shapefcn are of the form:


These terms are listed in sort order that of an N-dimensional array, with i1 varying first, then i2, and so on. Each Fj can itself be a multi-dimensional basis function expansion.


collapse all

Create a two-dimensional basis of polynomial functions to second-order in both variables.

Define a one-dimensional set of basis functions.

F = @(x)[x,x^2];

Equivalently, you can use polyBasis to create F.

F = polyBasis('canonical',2);

Generate a two-dimensional expansion from F.

F2D = ndBasis(F,F);

F2D is a function of two variables. The function returns a vector containing the evaluated basis functions of those two variables:


To confirm this, evaluate F2D for x = 0.2, y = -0.3.

ans = 1×8

    0.2000    0.0400   -0.3000   -0.0600   -0.0120    0.0900    0.0180    0.0036

The expansion you combine with ndBasis need not have the same order. For instance, combine F with first-order expansion in one variable.

G = @(y)[y];
F2D2 = ndBasis(F,G);

The array returned by F2D2 is similar to that returned by F2D, without the terms that are quadratic in the second variable.


Evaluate F2D2 for x = 0.2, y = -0.3 to confirm the order of terms.

ans = 1×5

    0.2000    0.0400   -0.3000   -0.0600   -0.0120

Create a set of two-dimensional basis functions where the expansion is quadratic in one variable and periodic in the other variable.

First generate the one-dimensional expansions. Name the variables for improved readability.

F1 = polyBasis('canonical',2,'x');
F2 = fourierBasis(1,1,'y');

For simplicity, this example takes only the first harmonic of the periodic variation. These expansions have basis functions given by:


Create the two-dimensional basis function expansion. Note that ndBasis preserves the variable names you assigned to one-dimensional expansions.

F = ndBasis(F1,F2)
F = function_handle with value:

The array returned by F includes all multiplicative combinations of the basis functions:


To confirm this, evaluate F for x = 0.2, y = -0.3.

ans = 1×8

    0.2000    0.0400    0.5878    0.1176    0.0235   -0.8090   -0.1618   -0.0324

Input Arguments

collapse all

Basis function expansion, specified as a function handle. The function must return a vector of basis functions of one or more scheduling variables. You can define these basis functions explicitly, or using polyBasis or fourierBasis.

Example: F = @(x)[x,x^2,x^3]

Example: F = polyBasis(3,2)

Output Arguments

collapse all

Basis function expansion, specified as a function handle. shapefcn takes as input arguments the total number of variables in F1,F2,...,FN. It returns a vector of functions of those variables, defined on the interval [–1,1] for each input variable. When you use shapefcn to create a gain surface, tunableSurface automatically generates tunable coefficients for each term in the vector.


  • The ndBasis operation is associative:

    ndBasis(F1,ndBasis(F2,F3)) = ndBasis(ndBasis(F1,F2),F3) = ndBasis(F1,F2,F3)

Introduced in R2015b