gainsurf

Create tunable gain surface for gain scheduling

gainsurf lets you express gain in terms of tunable parameters for tuning gain-scheduled controllers.

In gain-scheduled controllers, each controller gain, K(σ), is a function of the scheduling variables, σ. For tuning purposes, it is convenient to parameterize K(σ) as a smooth gain surface of the form:

K(σ)=K0+K1F1(σ)++KMFM(σ).

F1(σ),...,FM(σ) are user-selected basis functions. K0,...,KM are the coefficients to be tuned. You can use terms in a generic polynomial expansion as basis functions. Or, when you have a priori knowledge of the expected shape of K(σ), you can use more specific functions. You can then use systune, to tune the coefficients K0,...,KM, subject to your design requirements.

Syntax

  • K = gainsurf(name,K0init,F1,...,FM) example

Description

example

K = gainsurf(name,K0init,F1,...,FM) constructs a tunable model of the gain surface K(σ)=K0+K1F1(σ)++KMFM(σ), sampled at a discrete set of σ values (the design points). The arrays F1,...,FM contain the values of the basis functions F1(σ),...,FM(σ) at those design points. The gain surface model, K, depends on the tunable coefficients K0,...,KM. You can combine K with other static or dynamic elements to construct a closed-loop model of your gain-scheduled control system. Then, use systune to tune K0,...,KM so that the closed-loop system meets your design requirements at the selected design points.

Examples

expand all

Tunable Gain With One Scheduling Variable

Create a scalar gain K that varies as a quadratic function of a single scheduling variable, t:

$$K(t) = K_{0} + K_{1}t + K_{2}t^{2}.$$

This gain surface can represent a gain that varies with time. The coefficients $K_{0}$, $K_{1}$, and $K_{2}$ are the tunable parameters of this time-varying gain.

To represent the tunable gain surface K(t) in MATLAB®, first choose a vector of t values in the range of interest for your problem. Then, obtain the values of each basis function in the expansion of K(t), at those t values. For this example, suppose that t varies from 0 to 40.

t = 0:5:40;
F1 = t;
F2 = t.^2;

Create a tunable model of the gain surface K(t), sampled at the t values.

K = gainsurf('K',1,F1,F2)
K =

  1x9 array of generalized matrices with 1 rows, 1 columns, and the following blocks:
    K_0: Scalar parameter, 1 occurrences.
    K_1: Scalar parameter, 1 occurrences.
    K_2: Scalar parameter, 1 occurrences.

Type "double(K)" to see the current value, "get(K)" to see all properties, and "K.Blocks" to interact with the blocks.

K is an array of generalized matrices. Each element in K describes K(t) for a particular value of t, and depends on the tunable coefficients K_0, K_1, and K_2. For example, the first element, K(:,:,1), is $K(0) = K_{0} + K_{1}*0 + K_{2}*0^{2} = K_{0}$. The second element, K(:,:,2), is $K(5) = K_{0} + K_{1}*5 + K_{2}*5^{2}$, and so on.

Associate the independent variable values with the corresponding values of K.

K.SamplingGrid = struct('time',t);

The SamplingGrid property keeps track of the scheduling variable values associated with each entry in K. This association is convenient for tracing results back to independent variable values. For instance, you can use view(K) to inspect the tuned values of the gain surface after tuning. When you do so, view takes the axis range and labels from the entries in SamplingGrid. For this example, instead of tuning, manually set the values of the tunable blocks to non-zero values. View the resulting gain as a function of time.

values = struct('K_0',1,'K_1',-1,'K_2',0.1);
view(setBlockValue(K,values))

You can use K as a tunable gain to design a gain-scheduled controller. Use systune to tune the coefficients $K_{0}$, $K_{1}$, and $K_{2}$ at the sample times t = 0,5,...,40.

Tunable Gain With Two Independent Scheduling Variables

This example shows how to model a scalar gain K with a bilinear dependence on two scheduling variables, $\alpha$ and V, as follows:

$$K\left( {\alpha,V} \right) = {K_0} + {K_1}\alpha  + {K_2}V + {K_3}\alpha V .$$

For this example, $\alpha$ is an angle of incidence that ranges from 0 to 15 degrees, and V is a speed that ranges from 300 to 600 m/s. The coefficients $K_{0},...,K_{3}$ are the tunable parameters of this variable gain.

Create a grid of design points, $(\alpha,V)$, that are linearly spaced in $\alpha$ and V. These design points are where you will tune the gain surface coefficients.

[alpha,V] = ndgrid(0:5:15,300:100:600);

These arrays, alpha and V, represent the independent variation of the two scheduling variables, each across its full range.

When you tune the gain surface coefficients with systune, you might obtain better solver performance by normalizing the scheduling variables to fall within the interval [-1,1]. Scale the $\alpha$ and V grid to fall within this range.

alphaN = alpha/15;
VN = (V-450)/150;

Create the tunable gain surface sampled at the grid of $(\alpha_{N},V_{N})$ values:

$$K\left( {{\alpha _N},{V_N}} \right) = {K_0} + {K_1}{\alpha _N} + {K_2}{V_N} + {K_3}{\alpha _N}{V_N}.$$

In this expansion, the basis functions are:

$$\begin{array}{l}{F_1}\left( {{\alpha _N},{V_N}} \right) = {\alpha _N}\\{F_2}\left( {{\alpha _N},{V_N}} \right) = {V_N}\\{F_3}\left( {{\alpha _N},{V_N}} \right) = {\alpha _N}{V_N}.\end{array}$$

Specify the values of the basis functions over the $(\alpha_{N},V_{N})$.

F1 = alphaN;
F2 = VN;
F3 = alphaN.*VN;

K = gainsurf('K',1,F1,F2,F3)
K =

  4x4 array of generalized matrices with 1 rows, 1 columns, and the following blocks:
    K_0: Scalar parameter, 1 occurrences.
    K_1: Scalar parameter, 1 occurrences.
    K_2: Scalar parameter, 1 occurrences.
    K_3: Scalar parameter, 1 occurrences.

Type "double(K)" to see the current value, "get(K)" to see all properties, and "K.Blocks" to interact with the blocks.

K is an array of generalized matrices. Each element in K corresponds to $K(\alpha_{N},V_{N})$ for a particular $(\alpha_{N},V_{N})$ pair, and depends on the tunable coefficients K_0,...,|K_3|.

Associate the independent variable values with the corresponding values of K.

K.SamplingGrid = struct('alpha',alpha,'V',V);

The SamplingGrid property keeps track of the scheduling variable values associated with each entry in K. This association is convenient for tracing results back to independent variable values. For instance, you can use view(K) to inspect the tuned values of the gain surface after tuning. When you do so, view takes the axis range and labels from the entries in SamplingGrid. For this example, instead of tuning, manually set the values of the tunable blocks to non-zero values. View the resulting gain surface as a function of the scheduling variables.

values = struct('K_0',1,'K_1',-1,'K_2',0.1,'K_3',-0.2);
Ktuned = setBlockValue(K,values);
view(Ktuned)

The variable names and values that you specified in the SamplingGrid property are used to scale and label the axes.

You can use K as a tunable gain to build a control system with gain-scheduled tunable components. For example, use K to create a gain-scheduled low-pass filter.

F = tf(K,[1 K]);

You can use gain surfaces as arguments to model creation commands like tf the same way you would use numeric arguments. The resulting filter is a generalized state-space (genss) model array that depends on the four coefficients of the gain surface.

Use model interconnection commands (such as connect and feedback) to combine F with an array of plant models sampled at the same values of $\alpha$ and V. You can then use systune to tune the gain-scheduled controller to meet your design requirements. Because you normalized the scheduling variables to model the tunable gain, you must adjust the coefficient values in the implementation of your tuned controller.

Gain Surface Over Nonregular Grid

Create a gain surface sampled at scheduling variable values that do not form a regular grid in the operating domain. The gain surface varies as a bilinear function of variables $\alpha$ and $\beta$:

$$K(\alpha,\beta) = K_{0} + K_{1}\alpha + K_{2}\beta + K_{3}\alpha\beta.$$

Suppose that the values of interest of the scheduling variables are the following $(\alpha,\beta)$ pairs.

$$\left( {\alpha ,\beta } \right) = \left\{ {\begin{array}{l}
{( - 0.9,0.05)}\\
{( - 1.5,0.6)}\\
{( - 1.5,0.95)}\\
{( - 2.5,0.5)}\\
{( - 3.2,0.7)}\\
{( - 3.9,0.3)}
\end{array}} \right..$$

Specify the $(\alpha,\beta)$ sample values as vectors.

alpha = [-0.9;-1.5;-1.5;-2.5;-3.2;-3.9];
beta = [0.05;0.6;0.95;0.5;0.7;0.3];

Instead of a regular grid of $(\alpha,\beta)$ values, here the gain surface is sampled at irregularly spaced points on $(\alpha,\beta)$-space.

plot(alpha,beta,'o')

The basis functions of the expansion of $K$ are:

  • $F_{1} = \alpha$

  • $F_{2} = \beta$

  • $F_{3} = \alpha\beta$

Evaluate the basis functions at each of the sample points.

F1 = alpha;
F2 = beta;
F3 = alpha.*beta;

Create the tunable model of the gain surface using these sampled function values.

K = gainsurf('K',1,F1,F2,F3)
K =

  6x1 array of generalized matrices with 1 rows, 1 columns, and the following blocks:
    K_0: Scalar parameter, 1 occurrences.
    K_1: Scalar parameter, 1 occurrences.
    K_2: Scalar parameter, 1 occurrences.
    K_3: Scalar parameter, 1 occurrences.

Type "double(K)" to see the current value, "get(K)" to see all properties, and "K.Blocks" to interact with the blocks.

The gain surface is represented by a 6-by-1 array of generalized matrices. Because K is a scalar gain, each element in the array is 1-by-1. Each element in the array represents $K(\alpha,\beta)$ for the corresponding $(\alpha,\beta)$ sample. Each of these elements depends on the tunable parameters K_0,...,K_3.

Use the SamplingGrid property to associate the $\alpha$ and $\beta$ values with the corresponding entries in K.

SG = struct('alpha',alpha,'beta',beta);
K.SamplingGrid = SG;

Input Arguments

expand all

name — Identifying label for the tunable gainstring

Identifying label for the tunable gain surface, specified as a string. The tunable coefficients of the gain surface are assigned names based on this identifying label. For example, suppose you create a gain surface using the name Kp. The tunable coefficients are realp blocks in the resulting genmat. These blocks have names Kp_0, Kp_1,...,Kp_M.

Additionally, you can use this label to refer to the gain surface. For example, you can extract tuned coefficient values from a control system model, M, that depends on the gain surface using [K0,K1,...,KM] = gainsurfdata(M,'Kname').

K0init — Initial value of K0scalar | array

Initial value of the tunable coefficient K0, specified as a scalar or an array. The dimensions of K0init determine the I/O dimensions of the gain surface. For example, if the gain surface represents a two-input, two-output gain, you can set K0init = zeros(2). Doing so automatically sets the I/O dimensions of the other terms in the gain surface.

F1,...,FM — Values of the basis functions at sample values of scheduling variablesnumeric arrays

Function values describing the dependence of the gain surface on the scheduling variables, specified as numeric arrays. Each Fj(σ) in the expansion of the gain surface is a scalar-valued function. The corresponding input argument, Fj, is a numeric array containing the values of Fj(σ) at the corresponding scheduling variable values. For instance, in the following illustration, Fj(σ) is a function of two scheduling variables. The corresponding matrix FJ contains the values of Fj(σ) sampled over a 2-D grid of (σ1,σ2) values.

To construct the arguments F1,...,FM when your sampling grid is regular, evaluate each Fj(σ) over that grid. For example, consider a gain that depends on two scheduling variables, α and β:

K(α,β)=K0+K1αβ+K2α+K3β.

For this gain, F1 = αβ, F2 = α, and F3 = β. To create the input argument F1, you first create a grid of α and β values that spans the operating range of these variables. Then, you compute the values of F1 over that grid.

[alpha,beta] = ndgrid(0:1:10,50:5:100);
F1 = alpha.*beta;

You can improve performance of the tuning algorithm by specifying the function values in terms of normalized scheduling variables that fall in the range [–1,1]. To do this, subtract the mean value from each variable grid and divide by the variable's half-range. For example:

alphaN = (alpha-5)/5;
betaN = (beta-75)/25;
F1 = alphaN.*betaN;

In this example the values of α and β are regularly spaced. However, regular grid spacing is not required. Suppose your sampling values are arbitrary (α,β) pairs. In this case, α and β are specified as vectors, where (α(i),β(i) represents one sample point. Each Fj is also a vector:

Fj=[Fj(α1,β1),Fj(α2,β2),,Fj(αN,βN)].

For an example, see Gain Surface Over Nonregular Grid.

Output Arguments

expand all

K — Tunable gain surfacegeneralized matrix

Tunable gain surface, returned as an array of generalized matrices (genmat).

The dimensions of each generalized matrix in the array (the I/O dimensions of the gain surface) are determined by the dimensions of K0init. The dimensions of the array itself are determined by the sampling grid used to specify the basis functions. Thus, each entry in the array represents the gain at the corresponding scheduling variable value.

The gain surface depends on the tunable coefficients K0,...,KM. Each coefficient is modeled as a realp block of the same size as K. For instance, if the gain surface models a scalar gain, then each coefficient is a scalar realp block. If the gain surface models a 2-by-3 gain matrix, then each coefficient is a 2-by-3 realp block.

See Also

Functions

Was this topic helpful?