loopsyn
Loopshaping controller design with tradeoff between performance and robustness
Syntax
Description
loopsyn
balances performance and robustness by blending two
loopshaping methods.
You can adjust the tradeoff between performance and robustness to obtain satisfactory timedomain responses while avoiding fragile designs with plant inversion or flexible mode cancellation.
[
computes a stabilizing controller K
,CL
,gamma
,info
] = loopsyn(G
,Gd
)K
that shapes the openloop response
G*K
to approximately match the specified loop shape
Gd
. The mixedsensitivity performance gamma
indicates the closeness of the match. loopsyn
tries to minimize
gamma
, subject to the constraint that the robustness with
K
(as measured by ncfmargin
) is no worse than
half the maximum achievable robustness. The function also returns the closedloop transfer
function CL
and a structure info
containing
further information about the controller synthesis.
[
explicitly specifies the tradeoff between performance and robustness with parameter
K
,CL
,gamma
,info
] = loopsyn(G
,Gd
,alpha
)alpha
in the interval [0,1]. Within this interval, smaller
alpha
favors performance (mixsyn
design) and
larger alpha
favors robustness (ncfsyn
design).
When you specify alpha
, loopsyn
tries to minimize
gamma
, subject to the constraint that the robustness is no worse than
alpha
times the maximum achievable robustness.
Examples
Design LoopShaping Controller
Consider the following plant.
s = zpk('s');
G = (s10)/(s+100);
Design a controller that yields a closedloop step response with a rise time of about 4 s. A simple target loop shape for this requirement is Gd = wc/s
, where the target crossover frequency wc
is related to the desired rise time by t = 2/wc
.
wc = 0.5; Gd = wc/s;
Obtain the controller using loopsyn
.
[K,CL,gamma] = loopsyn(G,Gd); gamma
gamma = 1.1744
This value of gamma
is close to 1, indicating a fairly good match between the achieved loop shape and the target loop shape. Compare the achieved openloop response G*K
with the desired response Gd
.
sigma(G*K,"b",Gd,"r",{0.01,10}) grid on legend("Actual","Target")
Examine the step response of the closedloop system.
step(CL)
Specify Tradeoff Between Performance and Robustness
You can use the input argument alpha
to specify how much loopsyn
favors either performance (mixsyn
design) or robustness (ncfsyn
design). By default, loopsyn
computes a balanced design, alpha
= 0.5. To change the balance, change alpha
. Consider the following plant and target loop shape.
G = tf(25,[1 10 10 10]); Gd = tf(0.5,[1 0]);
Design a loopshaping controller that maximizes performance (minimizes gamma
) subject to the constraint that the robustness (as determined by ncfmargin
) is no worse than 75% of the maximum achievable robustness. To do so, set alpha
to 0.75.
alpha = 0.75; [K,CL,gamma,info] = loopsyn(G,Gd,alpha);
The maximum achievable robustness margin is returned in the info
structure. Compare that value to the margin achieved by this controller. For ncfmargin
, use the shaped plant and corresponding controller, also returned in info
.
info.emax
ans = 0.6474
ncfmargin(info.Gs,info.Ks)
ans = 0.4858
These values confirm that the achieved robustness is 75% of the maximum robustness achievable by setting alpha
= 1 for the pure ncfsyn
design. For this plant, the alpha
= 0.75 design yields a good match to the loop shape without sacrificing much robustness. Examine the performance and loop shape with this controller.
gamma
gamma = 1.2143
sigma(G*K,"b",Gd,"r",{0.01,10}) grid on legend("Actual","Target")
For details on how to choose a good value of alpha
for your application, see LoopShaping Controller Design.
Specify Different Shapes for Each Loop in MIMO System
When designing a controller for a MIMO system, if you specify a scalar Gd
, then loopsyn
applies the same target loop shape to all feedback channels. You can specify a different shape for each loop using a diagonal Gd
of size Ny
byNy
, where Ny
is the number of feedback loops, or the number of outputs of G
. Consider the following control system with a twooutput, twoinput plant.
s = tf('s');
G = [(1+0.1*s)/(1+s) 0.1/(s+2) ; 0 (s+2)/(s^2+s+3)];
Design a controller for this plant such as the first feedback channel has a crossover frequency of 1 rad/s and the second has a crossover frequency of 5 rad/s. To so, create the loop shapes wc/s
for each loop and use the append
command to create the diagonal Gd
.
wc = [1 5]; Gd = append(wc(1)/s,wc(2)/s);
Design the controller.
[K,CL] = loopsyn(G,Gd);
Compare the achieved loop shapes with the target loop shape.
bodemag(G*K,Gd,{0.1,100}) grid on legend("Actual","Target")
Specify Order of Tuned Controller
You can limit the order of the controller that loopsyn
designs using the order
argument. To specify a controller order, you must use a value of the parameter alpha
such that 0 < alpha < 1
.
Load a twoinput, twooutput plant.
load plant_loopsynOrderExample.mat G size(G)
Statespace model with 2 outputs, 2 inputs, and 7 states.
Design a controller for this plant with loop shape Gd = 0.5/s
. Use alpha = 0.5
and let loopsyn
select the controller order.
alpha = 0.5; Gd = tf(0.5,[1 0]); [K0,CL0,gamma0] = loopsyn(G,Gd,alpha); order(K0)
ans = 5
loopsyn
returns a controller with five states. Use loopsyn
again to design a threestate controller.
ord = 3; [K,CL,gamma,info] = loopsyn(G,Gd,alpha,ord); order(K)
ans = 3
For this plant, reducing the controller order from five to three yields a small decrease in performance.
gamma0
gamma0 = 1.0331
gamma
gamma = 1.1830
Use a modelreduction command such as balred
to identify suitable target orders to try for ord
.
TwoDegreeofFreedom LoopShaping Controller
loopsyn
can also provide a twoinput, one output controller suitable for implementing the twodegreeoffreedom (2DOF) architecture of the following illustration.
This architecture can be useful for mitigating the derivative kick that can occur when the reference signal changes. To obtain a controller suitable for this implementation, specify a plant and target loop shape, and call loopsyn
.
G = tf(8625,[1 2.389 5606]); Gd = tf(80,[1 0])*tf(240,[1 240]); [K,CL,gamma,info] = loopsyn(G,Gd);
The K2dof
field of the info
output contains the 2DOF controller. For a plant with Nu
inputs and Ny
outputs, K2dof
has Nu
outputs and 2*Ny
inputs. In this example, because G
is SISO, K2dof
has one output and two inputs.
K2dof = info.K2dof; size(K2dof)
Statespace model with 1 outputs, 2 inputs, and 4 states.
To use the controller, create a closedloop system with the architecture shown previously.
L2dof = G*K2dof; L2dof.InputName = {'r','y'}; L2dof.OutputName = 'y'; CL2dof = connect(L2dof,'r','y');
Compare the closedloop step response with the two architectures. For this system, the 2dof architecture substantially reduces the overshoot in the response.
step(CL,CL2dof) legend("1dof","2dof")
Input Arguments
G
— Plant
dynamic system model
Plant, specified as a dynamic system model such as a statespace
(ss
) model. If G
is a generalized statespace
model with uncertain or tunable control design blocks, then loopsyn
uses the nominal or current value of those elements. G
can be SISO
or MIMO, and can be a continuoustime or discretetime model. G
must have at least as many inputs as outputs. G
cannot have time
delays. Use pade
to approximate delays.
Gd
— Target loop shape
dynamic system model
Target loop shape, specified as a dynamic system model such as a
ss
, tf
, or zpk
model. You can also
provide Gd
as a frequencyresponse data (frd
)
model specifying the desired gain at specific frequencies. Gd
cannot have time delays. Use pade
to approximate delays.
For a MIMO plant G
with Ny
outputs:
Specify SISO
Gd
to use the same desired loop shape for all loops.Specify
Ny
byNy
diagonalGd
to use a different shape for each feedback loop. One way to construct such a diagonalGd
is to specify aGdi
for each channel, and then useGd = append(Gd1,...,GdNy)
.
In general, use a target loop shape that has high gain at low frequencies for reference tracking and disturbance rejection, and low gain at high frequencies for robustness against plant uncertainty. For more information about how to choose your target loop shape, see Loop Shaping for Performance and Robustness.
alpha
— Balance between performance and robustness
0.5 (default)  scalar in [0,1]
Balance between performance and robustness, specified as a scalar value in the range
[0,1]. Use alpha
to adjust the balance between performance and
robustness as follows:
alpha = 0
gives themixsyn
design.alpha = 1
gives thencfsyn
design.
loopsyn
maximizes performance (minimizes
gamma
) subject to the constraint that the robustness (as measured
by ncfmargin
) is no worse than alpha*emax
, where
emax
is the maximum robustness achievable by the
ncfsyn
design. The default value alpha = 0.5
yields a balanced design. You can adjust alpha
between 0 and 1 to
find the right tradeoff for your application. For an example that shows the effect of
varying alpha
, see LoopShaping Controller Design.
ord
— Controller order
positive integer
Controller order, specified as a positive integer. To use this option, you must
specify alpha
such that 0 <
alpha
<
1
.
Output Arguments
K
— Loopshaping controller
ss
model
Loopshaping controller, returned as a statespace (ss
) model.
K
shapes the openloop response G*K
to
approximately match the specified loop shape Gd
. The controller
minimizes the performance gamma
subject to the constraint that the
stability margin as computed by ncfmargin
does not exceed
alpha
*emax
, where emax
is
the maximum margin achievable by ncfsyn
.
CL
— Closedloop system
ss
model
Closedloop system, returned as a statespace (ss
) model. The
closedloop system is given by feedback(G*K,eye(ny))
, where
ny
is the number of outputs of G
.
gamma
— Controller performance
nonnegative scalar  Inf
Controller performance, returned as a nonnegative scalar value or
Inf
. A value near or below 1 indicates that G*K
is close to Gd
. Values much greater than one indicate a poor match
between the achieved and desired loop shapes. If loopsyn
cannot
find a stabilizing controller, gamma
is
Inf
.
gamma
is the mixedsensitivity performance, the cost function
minimized by mixsyn
, and is given by
$$\gamma ={\Vert \left[\begin{array}{c}{W}_{1}S\\ {W}_{3}T\end{array}\right]\Vert}_{\infty},\text{\hspace{1em}}S={\left(I+GK\right)}^{1},\text{\hspace{1em}}T=IS,$$
where W_{1} and
W_{3} are the mixsyn
weights. loopsyn
derives these weights from Gd
to enforce the desired loop shape.
info
— Additional information about controller synthesis
structure
Additional information about the controller synthesis, returned as a structure containing the following fields.
Field  Description 

W  Shaping prefilter, returned as a statespace (ss ) model.
The value of W is such that the shaped plant Gs =
G*W has the desired loop shape Gd . 
Gs  Shaped plant Gs = G*W , returned as an
ss model. 
Ks  H_{∞} controller for the shaped
plant Gs (see ncfsyn ), returned as an
ss model. For computing the robustness margin with ncfmargin , use
Gs and Ks . 
emax  Maximum achievable robustness margin, returned as a scalar. This value is
the robustness achieved by the pure ncfsyn design. For
information on interpreting this value, see ncfmargin . 
W1,W3  Weighting functions for the mixsyn formulation of the
loopshaping goal, returned as ss models.
loopsyn derives these weights from
Gd to enforce the desired loop shape. 
K2dof  Twodegreeoffreedom controller, returned as a For an example that shows how to use

Version History
Introduced before R2006aR2021b: loopsyn
ignores frequency range
Starting in R2021b, loopsyn
automatically generates a design that
balances performance and robustness. As a result of this change,
loopsyn
might return different results from previous releases.
Additionally, you can no longer specify a frequency range for loop shaping using the syntax
loopsyn(G,Gd,[wmin,wmax])
. The loopsyn
command
ignores any [wmin,wmax]
input. Further, the info
output structure no longer contains a Range
field.
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)