Simulink Control Design™ - MathWorks

(Tuis.) #1
Linear Analysis in a Loop with Fast Restart

In this example, you will trim and linearize a closed loop engine speed control model with
fastRestartForLinearAnalysis.

Open the engine speed control model and get the analysis points for linearization. This is
done to prevent re-compilation between the first call to findop and linearize.

model = 'scdspeedctrl';
open_system(model);
io = getlinio(model);
fopt = findopOptions('DisplayReport','off');

Configure the PI controller to use the base workspace variables kp and ki.

block = [model,'/PID Controller'];
set_param(block,'P','kp');
set_param(block,'I','ki');

Create a grid of parameters to vary.

vp = 0.0005:0.0005:0.003;
vi = 0.0025:0.0005:0.005;
[KP,KI] = ndgrid(vp,vi);
N = numel(KP);
sz = size(KP);

Initialize the base workspace variables kp and ki.

kp = KP(1);
ki = KI(1);

Turn fastRestartForLinearAnalysis on and use io as 'AnalysisPoints'.

fastRestartForLinearAnalysis(model,'on','AnalysisPoints',io);

Perform the linear analysis in a loop. Make sure the block initialization is called after the
parameters are updated when the model is in a compiled state.

ops = operspec(model); % operating point specifications
for i = N:-1:1
kp = KP(i);
ki = KI(i);
Simulink.Block.eval(block); % evaluate the block
op = findop(model,ops,fopt); % trim the model

15 Alphabetical List

Free download pdf