| Control System Toolbox™ | ![]() |
reg = lqg(sys,QXU,QWV)
reg = lqg(sys,QXU,QWV,QI)
reg = lqg(sys,QXU,QWV,QI,'1dof')
reg = lqg(sys,QXU,QWV,QI,'2dof')
reg = lqg(sys,QXU,QWV) computes an optimal LQG regulator reg given a state-space model sys of the plant and weighting matrices QXU and QWV. The dynamic regulator sys uses the measurements y to generate a control signal u that regulates y around the zero value. Use positive feedback to connect this regulator to the plant output y.

The LQG regulator minimizes the cost function
![]()
subject to the plant equations
dx/dt = Ax + Bu + w y = Cx + Du + v
where the process noise w and measurement noise v are Gaussian white noises with covariance:
E([w;v] * [w',v']) = QWV
reg = lqg(sys,QXU,QWV,QI) computes an LQG servo-controller reg that uses the setpoint command r and measurements y to generate the control signal u. reg has integral action to ensure that y tracks the command r.

The LQG servo-controller minimizes the cost function
![]()
where xi is the integral of the tracking error r - y. For MIMO systems, r, y, and xi must have the same length.
reg = lqg(sys,QXU,QWV,QI,'1dof') computes a one-degree-of-freedom servo controller that takes e = r - y rather than [r ; y] as input.
reg = lqg(sys,QXU,QWV,QI,'2dof') is equivalent to LQG(sys,QXU,QWV,QI) and produces the two-degree-of-freedom servo-controller shown previously.
lqg can be used for both continuous- and discrete-time plants. In discrete-time, lqg uses x[n|n-1] as state estimate (see kalman for details).
To compute the LQG regulator, lqg uses the commands lqr and kalman. To compute the servo-controller, lqg uses the commands lqi and kalman.
When you want more flexibility for designing regulators you can use the lqr, kalman, and lqgreg commands. When you want more flexibility for designing servo controllers, you can use the lqi, kalman, and lqgtrack commands. For more information on using these commands and how to decide when to use them, see Linear-Quadratic-Gaussian (LQG) Design for Regulation and Linear-Quadratic-Gaussian (LQG) Design of Servo Controller with Integral Action.
This example shows you how to design an LQG regulator, a one-degree-of-freedom LQG servo controller, and a two-degree-of-freedom LQG servo controller for the following system.

The plant has three states (x), two control inputs (u), three random inputs (w), one output (y), measurement noise for the output (v), and the following state and measurement equations.

where

The system has the following noise covariance data:

For the regulator, use the following cost function to define the tradeoff between regulation performance and control effort:
![]()
For the servo controllers, use the following cost function to define the tradeoff between tracker performance and control effort:
![]()
To design the LQG controllers for this system:
Create the state-space system by typing the following in the MATLAB Command Window:
A = [0 1 0;0 0 1;1 0 0]; B = [0.3 1;0 1;-0.3 0.9]; C = [1.9 1.3 1]; D = [0.53 -0.61]; sys = ss(A,B,C,D);
Define the noise covariance data and the weighting matrices by typing the following commands:
nx = 3; %Number of states ny = 1; %Number of outputs Qn = [4 2 0; 2 1 0; 0 0 1]; Rn = 0.7; R = [1 0;0 2] QXU = blkdiag(0.1*eye(nx),R); QWV = blkdiag(Qn,Rn); QI = eye(ny);
Form the LQG regulator by typing the following command:
KLQG = lqg(sys,QXU,QWV)
This command returns the following LQG regulator:
a =
x1_e x2_e x3_e
x1_e -6.212 -3.814 -4.136
x2_e -4.038 -3.196 -1.791
x3_e -1.418 -1.973 -1.766
b =
y1
x1_e 2.365
x2_e 1.432
x3_e 0.7684
c =
x1_e x2_e x3_e
u1 -0.02904 0.0008272 0.0303
u2 -0.7147 -0.7115 -0.7132
d =
y1
u1 0
u2 0
Input groups:
Name Channels
Measurement 1
Output groups:
Name Channels
Controls 1,2
Continuous-time model.Form the one-degree-of-freedom LQG servo controller by typing the following command:
KLQG1 = lqg(sys,QXU,QWV,QI,'1dof')
This command returns the following LQG servo controller:
a =
x1_e x2_e x3_e xi1
x1_e -7.626 -5.068 -4.891 0.9018
x2_e -5.108 -4.146 -2.362 0.6762
x3_e -2.121 -2.604 -2.141 0.4088
xi1 0 0 0 0
b =
e1
x1_e -2.365
x2_e -1.432
x3_e -0.7684
xi1 1
c =
x1_e x2_e x3_e xi1
u1 -0.5388 -0.4173 -0.2481 0.5578
u2 -1.492 -1.388 -1.131 0.5869
d =
e1
u1 0
u2 0
Input groups:
Name Channels
Error 1
Output groups:
Name Channels
Controls 1,2
Continuous-time model.Form the two-degree-of-freedom LQG servo controller by typing the following command:
KLQG2 = lqg(sys,QXU,QWV,QI,'2dof')
This command returns the following LQG servo controller:
a =
x1_e x2_e x3_e xi1
x1_e -7.626 -5.068 -4.891 0.9018
x2_e -5.108 -4.146 -2.362 0.6762
x3_e -2.121 -2.604 -2.141 0.4088
xi1 0 0 0 0
b =
r1 y1
x1_e 0 2.365
x2_e 0 1.432
x3_e 0 0.7684
xi1 1 -1
c =
x1_e x2_e x3_e xi1
u1 -0.5388 -0.4173 -0.2481 0.5578
u2 -1.492 -1.388 -1.131 0.5869
d =
r1 y1
u1 0 0
u2 0 0
Input groups:
Name Channels
Setpoint 1
Measurement 2
Output groups:
Name Channels
Controls 1,2
Continuous-time model.lqr, lqi, kalman, lqry, ss, care, dare
![]() | lft | lqgreg | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |