## Tune Gain Schedules in Simulink

Typically, gain-scheduled controllers are fixed single-loop or multiloop control
structures in which controller gains vary with operating condition. A gain schedule converts
the scheduling variables that describe the current operating condition into appropriate
controller gains. In Simulink^{®}, you can implement gain schedules using lookup tables or MATLAB^{®} functions. (See Model Gain-Scheduled Control Systems in Simulink.)

You can use
`systune`

to tune these gain schedules so that the full nonlinear system
meets your design requirements. Tuning gain schedules amounts to identifying appropriate
values for lookup-table data or finding the right function to embed in a MATLAB
Function block. For `systune`

, you parameterize the gain
schedules as functions of the scheduling variables with tunable coefficients.

### Workflow for Tuning Gain Schedules

The general workflow for tuning gain-scheduled control systems is:

Select a set of design points that adequately covers the operating range over which you are tuning. A

*design point*is a set of scheduling-variable values that describe a particular operating condition. The set of design points can be a regular grid of values or a scattered set. Typically, you start with a few design points. If the performance that your tuned system achieves at the design points is not maintained between design points, add more design points and retune.Obtain a collection of linear models describing the linearized plant dynamics at the selected design points. Ways to obtain the array of linear models include:

Linearize a Simulink model at each operating condition represented in the grid of design points. For example, if each design point corresponds to a steady-state operating condition, you can trim the plant at each design point and linearize at the resulting operating point. Or, if your scheduling variable is time, you can linearize at a series of simulation snapshots.

Sample an LPV model of the plant at the design points.

For more information, see Plant Models for Gain-Scheduled Controller Tuning.

Create an

`slTuner`

interface for tuning the Simulink. When you do so, you substitute the array of linear models for the plant, so that the`slTuner`

interface contains a set of closed-loop tunable models corresponding to each design point. For more information, see Multiple Design Points in slTuner Interface.Model the gain schedules as parametric gain surfaces. A

*parametric gain surface*is a basis-function expansion with tunable coefficients. For a vector*σ*of scheduling variables, such expansion is of the form:$$K\left(\sigma \right)={K}_{0}+{K}_{1}{F}_{1}\left(n\left(\sigma \right)\right)+\dots +{K}_{M}{F}_{M}\left(n\left(\sigma \right)\right).$$

*n*(*σ*) is a normalization function. For tuning with`systune`

, you use`tunableSurface`

to represent the parametric gain surface*K*(*σ*). In the`slTuner`

interface you create for tuning, use`setBlockParam`

to associate the resulting gain surface with the block that represents the gain schedule.`systune`

tunes the coefficients*K*_{0},...,*K*over all the design points._{M}For more information, see Parameterize Gain Schedules.

Specify your tuning goals using

`TuningGoal`

objects. You can specify tuning goals that apply at all design points or at a subset of design points. You can also specify tuning goals that vary from design point to design point. For example, you might define a minimum gain margin that becomes increasingly stringent as a particular scheduling variable increases in magnitude.For information about specifying tuning goals that vary with design point, see Change Requirements with Operating Condition.

For information about specifying tuning goals generally, see Tuning Goals.

Use

`systune`

to tune the control system.`systune`

tunes the set of parameters,*K*_{0},...,*K*, against all plant models in the design grid simultaneously (multimodel tuning)._{M}Validate the tuning results. You can examine the tuned gain surfaces and validate the performance of the linearized system at each design point. However, local linear performance does not guarantee global performance in nonlinear systems. Therefore, it is important to perform simulation-based validation using the tuned gain schedules.

For more information, see Validate Gain-Scheduled Control Systems.