This example shows how to use the slLinearizer interface to batch linearize a Simulink® model. You vary model parameter values and obtain multiple open-loop and closed-loop transfer functions from the model.
You can perform the same analysis using the linearize command. However, when you want to obtain multiple open-loop and closed-loop transfer functions, especially for models that are expensive to compile repeatedly, slLinearizer can be more efficient.
|On this page…|
Cascaded loop model
The scdcascade model contains a pair of cascaded feedback control loops. Each loop includes a PI controller. The plant models, G1 (outer loop) and G2 (inner loop), are LTI models.
Use the slLinearizer interface to analyze the inner- and outer-loop dynamics.
mdl = 'scdcascade'; open_system(mdl);
Create an slLinearizer interface for scdcascade.
sllin = slLinearizer(mdl)
slLinearizer linearization interface for "scdcascade": No analysis points. Use addPoint method to add new points. No permanent openings. Use addOpening method to add new permanent openings. Other properties (with dot notation get/set access): Parameters :  OperatingPoints :  (model initial condition will be used.) BlockSubstitutions :  Options : [1x1 linearize.LinearizeOptions]
Vary the inner-loop controller gains.
For inner-loop analysis, vary the gains of the inner-loop PI controller block, C2. Vary the proportional gain (Kp2) and integral gain (Ki2) in the 15% range.
Kp2_range = linspace(Kp2*0.85,Kp2*1.15,6); Ki2_range = linspace(Ki2*0.85,Ki2*1.15,4); [Kp2_grid, Ki2_grid] = ndgrid(Kp2_range,Ki2_range); params(1).Name = 'Kp2'; params(1).Value = Kp2_grid; params(2).Name = 'Ki2'; params(2).Value = Ki2_grid; sllin.Parameters = params;
Kp2_range and Ki2_range specify the sample values for Kp2 and Ki2. To obtain a transfer function for each combination of Kp2 and Ki2, use ndgrid and create a 6 x 4 parameter grid with grid arrays Kp2_grid and Ki2_grid. Configure the Parameters property of sllin with the structure params. This structure specifies the parameters to be varied and their grid arrays.
Analyze the overall closed-loop transfer function for the inner-loop.
The overall closed-loop transfer function for the inner loop is equal to the transfer function from u1 to y2. To eliminate the effects of the outer loop, you can break the loop at e1, y1m, or y1. For this example, break the loop at e1.
Add u1 and y2 as analysis points, and e1 as a permanent opening of sllin.
Obtain the transfer function from u1 to y2.
r2yi = getIOTransfer(sllin,'u1','y2');
r2yi, a 6 x 4 state-space model array, contains the transfer function for each specified parameter combination. The software uses the model initial conditions as the linearization operating point.
Because e1 is a permanent opening of sllin, r2yi does not include the effects of the outer loop.
Plot the step response for r2yi.
The step response for all models varies in the 10% range and the settling time is less than 1.5 seconds.
Analyze the inner-loop transfer function at the plant output.
Obtain the inner-loop transfer function at y2, with the outer loop open at e1.
Li = getLoopTransfer(sllin,'y2',-1);
Because the software assumes positive feedback by default and scdcascade uses negative feedback, specify the feedback sign using the third input argument. Now, Li = –G2C2.
Plot the bode response for Li.
The magnitude plot for all the models varies in the 3 dB range. The phase plot shows the most variation, approximately 20°, in the [1 10] rad/s interval.
Vary the outer-loop controller gains.
For outer-loop analysis, vary the gains of the outer-loop PI controller block, C1. Vary the proportional gain (Kp1) and integral gain (Ki1) in the 20% range.
Kp1_range = linspace(Kp1*0.8,Kp1*1.2,6); Ki1_range = linspace(Ki1*0.8,Ki1*1.2,4); [Kp1_grid, Ki1_grid] = ndgrid(Kp1_range,Ki1_range); params(1).Name = 'Kp1'; params(1).Value = Kp1_grid; params(2).Name = 'Ki1'; params(2).Value = Ki1_grid; sllin.Parameters = params;
Similar to the workflow for configuring the parameter grid for inner-loop analysis, create the structure, params, that specifies a 6 x 4 parameter grid. Reconfigure sllin.Parameters to use the new parameter grid. sllin now uses the default values for Kp2 and Ki2.
Analyze the closed-loop transfer function from the reference to the plant output.
Remove e1 from the list of permanent openings for sllin before proceeding with outer-loop analysis.
To obtain the closed-loop transfer function from the reference signal, r, to the plant output, y1m, add r and y1m as analysis points to sllin.
Obtain the transfer function from r to y1m.
r2yo = getIOTransfer(sllin,'r','y1m');
Plot the step response for r2yo.
The step response is underdamped for all the models.
Analyze the outer-loop sensitivity at the plant output.
To obtain the outer-loop sensitivity at the plant output, add y1 as an analysis point to sllin.
Obtain the outer-loop sensitivity at y1.
So = getSensitivity(sllin,'y1');
Plot the step response of So.
The plot indicates that it takes approximately 15 seconds to reject a step disturbance at the plant output, y1.
Close the model.