| Contents | Index |
looptune tunes the feedback loop illustrated below to meet default requirements or requirements that you specify.

C represents the controller and G represents the plant. The sensor outputsy (measurements) and actuator outputs u (controls) define the boundary between plant and controller. The controller is the portion of your control system whose inputs are measurements, and whose outputs are control signals. Conversely, the plant is the remainder—the portion of your control system that receives control signals as inputs, and produces measurements as outputs.
For example, in the control system of the following illustration, the controller C receives the measurement y, and the reference signal r. The controller produces the controls qL and qV as outputs.

The controller C has a fixed internal structure. C includes a gain matrix D , the PI controllers PI_L and PI_V, and a summing junction. The looptune command tunes free parameters of C such as the gains in D and the proportional and integral gains of PI_L and PI_V. You can also use looptune to co-tune free parameters in both C and G.
To set up your control system in MATLAB for tuning with looptune:
Create a tunable genss model representing the controller C.
Create a Numeric LTI model representing the plant G. For co-tuning the plant and controller, represent the plant as a tunable genss model.
To set up your control system in Simulink for tuning with slTunable.looptune (requires Simulink Control Design software):
Use slTunable to create an interface to the Simulink model of your control system. When you create the interface, you specify which blocks to tune in your model.
Use slTunable.addControl and slTunable.addMeasurement to specify the control and measurement signals that define the boundaries between plant and controller.
The slTunable interface automatically linearizes your Simulink model. The slTunable interface also automatically parametrizes the blocks that you specify as tunable blocks. For more information, see the slTunable reference page and Supported Blocks for Tuning in Simulink.
When you use looptune, you specify a target control bandwidth as a target open-loop gain crossover, the wc input to looptune.
By default, looptune automatically tunes your control system to enforce the following additional requirements:
Performance—integral action at low frequency
Roll-off—gain roll-off at frequencies above the crossover frequency
Stability margins—adequate robustness at frequencies above the crossover frequency
You can define custom performance specifications and robustness criteria that further constrain or override the default requirements. The following table summarizes the types of performance specifications and robustness criteria that you can specify.
| Specification Type | Description | How To Specify |
|---|---|---|
| Crossover frequency band | Frequency band into which gain crossover frequencies of open-loop response falls | wc argument to looptune or slTunable.looptune |
| Stability margins | Gain and phase margins, defined as multi-loop disk margins for MIMO systems (see loopmargin), Defaults are 7.6 dB gain margin, 45 degrees phase margin | looptuneOptions option set passed to looptune or slTunable.looptune |
| Custom design requirements | Constraints on the response across particular input/output
pairs, such as:
| TuningGoal requirement objects passed to looptune: |
This example shows how to tune the control system of the following illustration to achieve crossover between 0.1 and 1 rad/min, using looptune.

The setpoint signal r, the error signal e, and the output signal y are vector-valued signals of dimension 2. The 2-by-2 plant G is represented by:
![]()
Create a Numeric LTI model representing the plant.
s = tf('s');
G = 1/(75*s+1)*[87.8 -86.4; 108.2 -109.6];
G.InputName = {'qL','qV'};
G.OutputName = 'y';
Name the inputs and outputs of your model using the InputName and OutputName properties. Doing so tells looptune how to interconnect your plant and controller.
The controller, C, has a fixed structure that includes three tunable components: the 2-by-2 decoupling matrix, D, and the two PI controllers, PI_L and PI_V. (For more information about this control system, see the demo Decoupling Controller for a Distillation Column.)

C receives the measurement signal y and the reference r as inputs. C produces the control signals qL and qV.
Use Control Design Blocks to represent the tunable components of the controller.
D = ltiblock.gain('Decoupler',eye(2));
D.InputName = 'e';
D.OutputName = {'pL','pV'};
PI_L = ltiblock.pid('PI_L','pi');
PI_L.InputName = 'pL';
PI_L.OutputName = 'qL';
PI_V = ltiblock.pid('PI_V','pi');
PI_V.InputName = 'pV';
PI_V.OutputName = 'qV';
Create the summing junction using sumblk.
sum1 = sumblk('e = r - y',2);
Connect the components using model interconnection commands.
C0 = connect(PI_L,PI_V,D,sum1,{'r','y'},{'qL','qV'});
The genss model C0 represents the controller structure. C0 specifies which controller parameters are tunable, and contains the initial values of those parameters.
Tune the control system.
rng('default');
wc = [0.1,1];
options = looptuneOptions('RandomStart',5);
[G,C,gam,Info] = looptune(G,C0,wc,options);These commands produce a result similar to the following:
Final: Peak gain = 1.24, Iterations = 77
Final: Peak gain = 1.24, Iterations = 110
Final: Peak gain = 3.59, Iterations = 35
Spectral abscissa -1.92e-007 is close to bound -1e-007
Final: Peak gain = 1.24, Iterations = 86
Final: Peak gain = 1.24, Iterations = 134
Final: Peak gain = 1.24, Iterations = 89The looptune algorithm uses the input and output names of C0 and G to form the closed loop system for tuning. The input wc specifies that the crossover frequency of each loop in the system falls between 0.1 and 1 rad/min.
Setting RandomStart to 5 causes looptune to perform five additional optimization runs, beginning from parameter values it chooses randomly. Most runs return 1.24 as optimal gain value, suggesting that this local minimum has a wide region of attraction and is likely to be the global optimum.
The output gam is a normalized parameter indicating the degree of success meeting the tuning requirements. gam is the best value of the peak gain over all optimization runs. gam <=1 indicates that all requirements are satisfied. A gam value much greater than one indicates failure to meet some requirement. In this example, the best value of gam = 1.24 indicates a reasonable degree of success meeting the specified crossover requirement.
looptune also returns C, the tuned version of C0 that yields the best peak gain value. Examine the tuned values of all components using showBlockValue.
showBlockValue(C)
Decoupler =
d =
e(1) e(2)
pL 3.302 -2.039
pV 7.759 -8.021
Name: Decoupler
Static gain.
-----------------------------------
PI_L =
1
Kp + Ki * ---
s
with Kp = 0.717, Ki = 0.0261
Name: PI_L
Continuous-time PI controller in parallel form.
-----------------------------------
PI_V =
1
Kp + Ki * ---
s
with Kp = 0.236, Ki = 0.0086
Name: PI_V
Continuous-time PI controller in parallel form.Validate the frequency domain response of the tuned result using loopview.
loopview(G,C,Info)

The first plot shows that the open-loop gain crossovers fall close to the specified interval [0.1,1]. This plot also includes the maximum and tuned values of the sensitivity function S = (I – GC)–1 and complementary sensitivity T = I – S. The curve marked S/T Max shows the maximum allowed gain for S on the low-frequency side of the plot, and the maximum allowed gain for T on the high-frequency side. These curves are the constraints that looptune imposes on S and T to enforce the target crossover range wc.
The second plot shows that the MIMO stability margins of the tuned system (blue curve) do not significantly exceed the upper limit (yellow curve).
Validate the time domain response using Control System Toolbox analysis commands such as step.
T = connect(G,C,'r','y'); step(T)

The tuned controller provides good setpoint tracking with reasonably small crosstalk between channels. To impose further constraints on crosstalk, use the TuningGoal.MaxGain requirements object.
This example shows how to tune the control system of the following illustration to make the signal az track the reference signal r with a 1 s response time.

Load the plant.
load looptune_ex G
G.InputName = 'df';
G.OutputName = {'az','q'};G is a 1-input, 2-output state-space model. Naming the inputs and outputs of G tells the software how to connect the plant and controller when tuning the control system.
The controller C is the portion of the control system that receives the measurement signals q and az, and produces the control signal df. Create a tunable model of the controller using Control Design Blocks, summing junctions, and connect.
PI = ltiblock.pid('PI','pi');
PI.InputName = 'e'; PI.OutputName = 'qref';
qgain = ltiblock.gain('qgain',0);
Cdf = qgain*tf(1,[1 0]);
Cdf.InputName = 'qsum'; Cdf.OutputName = 'df';
sum1 = sumblk('e = r - az');
sum2 = sumblk('qsum = qref + q');
C0 = connect(PI,Cdf,sum1,sum2,{'r','az','q'},'df');C0 is a genss model. The tunable parameters of C0 are the proportional and integral gains of the PI controller PI, and the gain of qgain.
Tune the control system. Use a target bandwidth range of [3,12] to get a response time on the order of 1 s.
rng('default');
Options = looptuneOptions('RandomStart',4);
[G,C,gam,Info] = looptune(G,C0,[3,12],Options);Examine the frequency-domain performance of the tuned controller C.
loopview(G,C,Info)

The crossover frequency is at approximately 4 rad/s. The stability margin requirement is also met.
Examine the closed-loop time-domain response of the tuned control system to see how well az tracks the reference signal r. Use the tuned controller C to form the closed-loop response. C is a genss model whose current parameter values are the tuned values.
T = connect(G,C,'r','az'); step(T,5)

In the time domain, it is clear that the output does not track the reference signal, despite the presence of an integrator in the loop. This result occurs because the feedback loop acts on both signals az and q. The controller does not know what combination of az and q should track the reference r.
Use a TuningGoal.Tracking requirement object to add the tracking constraint to the optimization performed by looptune.
Req = TuningGoal.Tracking('r','az',1);Tune the control system again using the tracking requirement.
rng('default');
[G,C,gam,Info] = looptune(G,C0,[3,12],Req,Options);Validate the new design.
T = connect(G,C,'r','az'); step(T,5)

The response now meets the tuning design requirements of good reference tracking with a response time of about 1 s.
The following demos show how to use the slTunable interface to tune a Simulink model with looptune. Running these demos requires Simulink Control Design.
![]() | Tuning Fixed-Structure Control Systems | H-Infinity Tuning with hinfstruct | ![]() |

Learn more about resources for designing, testing, and implementing control systems.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |