MATLAB Examples

Set Up for Gain Scheduling by Linearizing at Design Points

This example shows how to linearize a plant model at a set of design points for tuning of a gain-scheduled controller. The example then uses the resulting linearized models to configure an slTuner interface for tuning the gain schedule.


Open the rct_CSTR model.

mdl = fullfile(matlabroot,'examples','controls_id','rct_CSTR.slx');

In this model, the Concentration controller and Temperature controller both depend on the output concentration Cr. To set up this gain-scheduled system for tuning, you linearize the plant at a set of steady-state operating points that correspond to different values of the scheduling parameter Cr. Sometimes, it is convenient to use a separate model of the plant for trimming and linearization under various operating conditions. For example, in this case, the most straightforward way to obtain these linearizations is to use a separate open-loop model of the plant, rct_CSTR_OL.

mdl_OL = fullfile(matlabroot,'examples','controls_id','rct_CSTR_OL.slx');

Trim Plant at Design Points

Suppose that you want to control this plant at a range of Cr values from 4 to 8. Trim the model to find steady-state operating points for a set of values in this range. These values are the design points for tuning.

Cr = (4:8)';        % concentrations
for k=1:length(Cr)
   opspec = operspec('rct_CSTR_OL');
   % Set desired residual concentration
   opspec.Outputs(1).y = Cr(k);
   opspec.Outputs(1).Known = true;
   % Compute equilibrium condition
   [op(k),report(k)] = findop('rct_CSTR_OL',opspec,findopOptions('DisplayReport','off'));

op is an array of steady-state operating points. (For more information about steady-state operating points, see docid:slcontrol_ug.buvw_gr in the Simulink Control Design documentation.)

Linearize at Design Points

Linearizing the plant model using op returns an array of LTI models, each linearized at the corresponding design point.

G = linearize('rct_CSTR_OL','rct_CSTR_OL/CSTR',op);

Create slTuner Interface with Block Substitution

To tune the control system rct_CSTR, create an slTuner interface that linearizes the system at those design points. Use block substitution to replace the plant in rct_CSTR with the linearized plant-model array G.

blocksub.Name = 'rct_CSTR/CSTR';
blocksub.Value = G;
tunedblocks = {'Kp','Ki'};
ST0 = slTuner('rct_CSTR',tunedblocks,blocksub);

For this example, only the PI coefficients in the Concentration controller are designated as tuned blocks. In general, however, tunedblocks lists all the blocks to tune.

For more information about using block substitution to configure an slTuner interface for gain-scheduled controller tuning, see docid:control_ug.mw_ea1e7c85-3136-48ff-9e9d-4e9ac0ed023e.

For another example that illustrates using trimming and linearization to generate a family of linear models for gain-scheduled controller tuning, see docid:control_examples.ex-HL20TrimLinearizeExample.