Main Content

fourierBasis

Fourier basis functions for tunable gain surface

Description

You use basis function expansions to parameterize gain surfaces for tuning gain-scheduled controllers. fourierBasis generates periodic Fourier series expansions for parameterizing gain surfaces that depend periodically on the scheduling variables, such as a gain that varies with angular position. Use the output of fourierBasis to create tunable gain surfaces with tunableSurface.

shapefcn = fourierBasis(N) generates a function that evaluates the first N harmonics of eiπx:

F(x)=[cos(πx),sin(πx),cos(2πx),sin(2πx),,cos(Nπx),sin(Nπx)].

F is the function represented by shapefcn. The term of F are the first 2*N basis functions in the Fourier series expansion of a periodically varying gain, K(x), with K(–1) = K(1). That expansion is given by:

K(x)=a02+k{akcos(kπx)+bksin(kπx)}.

example

shapefcn = fourierBasis(N,nvars) generates an nvars-dimensional Fourier basis for periodic functions on the region [–1,1]nvars. This basis is the outer product of nvars Fourier bases with N harmonics along each dimension. The resulting function shapefcn takes nvars input arguments and returns a vector with (2*N+1)^(nvars-1)-1 entries.

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

example

shapefcn = fourierBasis(___,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.

Examples

collapse all

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

shapefcn = fourierBasis(2);

shapefcn is a handle to a function of one variable that returns an array of four values corresponding to the first two harmonics of a periodic function on x = [–1,1]:

F(x)=[cos(πx),sin(πx),cos(2πx),sin(2πx)].

Use shapefcn as an input argument to tunableSurface to define a gain surface of the form:

K(x)=K0+K1cos(πx)+K2sin(πx)+K3cos(2πx)+K4sin(2πx).

The variable x is a normalized version of the scheduling variable for your tunable surface. Because the basis functions created by fourierBasis act on normalized variables, your gain-scheduled system must use design points whose endpoint values delineate exactly one period. For example, suppose you use the following design points:

alpha = [-7,-4,-1,2,5];
domain = struct('alpha',alpha);
K = tunableSurface('K',0,domain,shapefcn);

In normalizing the domain, the software assumes that the gain surface, K, is periodic in alpha such that K(-7) = K(5).

Create a two-dimensional Fourier basis for periodic functions of x and y on the domain [-1,1]N. The basis functions should go up to the third harmonic in both the x and y dimensions.

F2D = fourierBasis(3,2);

This function is the outer product of two vectors:

x = fourierBasis(3);
y = fourierBasis(3);

Equivalently, you can obtain the outer product using ndBasis.

F = fourierBasis(3);
F2D = ndBasis(F,F);

The values in the vector returned by F include cross-terms such as sin(πx)cos(πy) and sin(3πx)cos(2πy).

Input Arguments

collapse all

Number of harmonics of Fourier 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

Fourier expansion, specified as a function handle. shapefcn takes as input arguments the number of variables specified by nvars. It returns a vector of polynomials in 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 polynomial term in the vector.

Tips

  • If the gain surface K is periodic in the scheduling variable x with period P, make sure that the corresponding entry in K.Normalization.InputScaling is set to P/2 to ensure consistency with the fourierBasis period, P = 2. When using the default normalization, the x values in K.SamplingGrid must span exactly one period, [a, a+P], to satisfy this requirement. See the Normalization property of tunableSurface for more details.

Version History

Introduced in R2015b