Linear-quadratic-Gaussian (LQG) control is a modern state-space technique for designing optimal dynamic regulators and servo controllers with integral action (also known as setpoint trackers). This technique allows you to trade off regulation/tracker performance and control effort, and to take into account process disturbances and measurement noise.

To design LQG regulators and setpoint trackers, you perform the following steps:

1. Construct the LQ-optimal gain.

2. Construct a Kalman filter (state estimator).

3. Form the LQG design by connecting the LQ-optimal gain and the Kalman filter.

These topics focus on the continuous-time case. For information about discrete-time LQG design, see the dlqr and kalman reference pages.

### Linear-Quadratic-Gaussian (LQG) Design for Regulation

You can design an LQG regulator to regulate the output y around zero in the following model.

The plant in this model experiences disturbances (process noise) w and is driven by controls u. The regulator relies on the noisy measurements y to generate these controls. The plant state and measurement equations take the form of

$\begin{array}{l}\stackrel{˙}{x}=Ax+Bu+Gw\\ y=Cx+Du+Hw+v\end{array}$

and both w and v are modeled as white noise.

### Note

LQG design requires a state-space model of the plant. You can use ss to convert other model formats to state space.

To design LQG regulators, you can use the design techniques shown in the following table.

To design an LQG regulator using...Use the following commands:

A quick, one-step design technique when the following is true:

• You need the optimal LQG controller and either E(wv') or H is nonzero.

• All known (deterministic) inputs are control inputs and all outputs are measured.

• Integrator states are weighted independently of states of plants and control inputs.

lqg

A more flexible, three-step design technique that allows you to specify:

• Arbitrary G and H.

• Known (deterministic) inputs that are not controls and/or outputs that are not measured.

• A flexible weighting scheme for integrator states, plant states, and controls.

lqr, kalman, and lqgreg

#### Constructing the Optimal State-Feedback Gain for Regulation

You construct the LQ-optimal gain from the following elements:

• State-space system matrices

• Weighting matrices Q, R, and N, which define the tradeoff between regulation performance (how fast x(t) goes to zero) and control effort.

To construct the optimal gain, type the following command:

K= lqr(A,B,Q,R,N)

This command computes the optimal gain matrix K, for which the state feedback law $u=-Kx$ minimizes the following quadratic cost function for continuous time:

$J\left(u\right)={\int }_{0}^{\infty }\left\{{x}^{T}Qx+2{x}^{T}Nu+{u}^{T}Ru\right\}dt$

The software computes the gain matrix K by solving an algebraic Riccati equation.

For information about constructing LQ-optimal gain, including the cost function that the software minimizes for discrete time, see the lqr reference page.

#### Constructing the Kalman State Estimator

You need a Kalman state estimator for LQG regulation and servo control because you cannot implement optimal LQ-optimal state feedback without full state measurement.

You construct the state estimate $\stackrel{^}{x}$ such that $u=-K\stackrel{^}{x}$ remains optimal for the output-feedback problem. You construct the Kalman state estimator gain from the following elements:

• State-space plant model sys

• Noise covariance data, Qn, Rn, and Nn

The following figure shows the required dimensions for Qn, Rn, and Nn. If Nn is 0, you can omit it.

Required Dimensions for Qn, Rn, and Nn

### Note

You construct the Kalman state estimator in the same way for both regulation and servo control.

To construct the Kalman state estimator, type the following command:

[kest,L,P] = kalman(sys,Qn,Rn,Nn);

This command computes a Kalman state estimator, kest with the following plant equations:

$\begin{array}{l}\stackrel{˙}{x}=Ax+Bu+Gw\\ y=Cx+Du+Hw+v\end{array}$

where w and v are modeled as white noise. L is the Kalman gain and P the covariance matrix.

The software generates this state estimate using the Kalman filter

$\frac{d}{dt}\stackrel{^}{x}=A\stackrel{^}{x}+Bu+L\left(y-C\stackrel{^}{x}-Du\right)$

with inputs u (controls) and y (measurements). The noise covariance data

$E\left(w{w}^{T}\right)={Q}_{n},\text{ }E\left(v{v}^{T}\right)={R}_{n},\text{ }E\left(w{v}^{T}\right)={N}_{n}$

determines the Kalman gain L through an algebraic Riccati equation.

The Kalman filter is an optimal estimator when dealing with Gaussian white noise. Specifically, it minimizes the asymptotic covariance
$E\left(\left(x-\stackrel{^}{x}\right){\left(x-\stackrel{^}{x}\right)}^{T}\right)$

of the estimation error $x-\stackrel{^}{x}$.

For more information, see the kalman reference page. For a complete example of a Kalman filter implementation, see Kalman Filtering.

#### Forming the LQG Regulator

To form the LQG regulator, connect the Kalman filter kest and LQ-optimal gain K by typing the following command:

regulator = lqgreg(kest, K);
This command forms the LQG regulator shown in the following figure.

The regulator has the following state-space equations:

$\begin{array}{l}\frac{d}{dt}\stackrel{^}{x}=\left[A-LC-\left(B-LD\right)K\right]\stackrel{^}{x}+Ly\\ u=-K\stackrel{^}{x}\end{array}$

For more information on forming LQG regulators, see lqgreg and LQG Regulation: Rolling Mill Case Study.

### Linear-Quadratic-Gaussian (LQG) Design of Servo Controller with Integral Action

You can design a servo controller with integral action for the following model:

The servo controller you design ensures that the output y tracks the reference command r while rejecting process disturbances w and measurement noise v.

The plant in the previous figure is subject to disturbances w and is driven by controls u. The servo controller relies on the noisy measurements y to generate these controls. The plant state and measurement equations are of the form

$\begin{array}{l}\stackrel{˙}{x}=Ax+Bu+Gw\\ y=Cx+Du+Hw+v\end{array}$

and both w and v are modeled as white noise.

### Note

LQG design requires a state-space model of the plant. You can use ss to convert other model formats to state space.

To design LQG servo controllers, you can use the design techniques shown in the following table.

To design an LQG servo controller using...Use the following commands:

A quick, one-step design technique when the following is true:

• You need the optimal LQG controller and either E(wv') or H is nonzero.

• All known (deterministic) inputs are control inputs and all outputs are measured.

• Integrator states are weighted independently of states of plants and control inputs.

lqg

A more flexible, three-step design technique that allows you to specify:

• Arbitrary G and H.

• Known (deterministic) inputs that are not controls and/or outputs that are not measured.

• A flexible weighting scheme for integrator states, plant states, and controls.

lqi, kalman, and lqgtrack

#### Constructing the Optimal State-Feedback Gain for Servo Control

You construct the LQ-optimal gain from the

• State-space plant model sys

• Weighting matrices Q, R, and N, which define the tradeoff between tracker performance and control effort

To construct the optimal gain, type the following command:

K= lqi(sys,Q,R,N)

This command computes the optimal gain matrix K, for which the state feedback law $u=-Kz=-K\left[x;{x}_{i}\right]$ minimizes the following quadratic cost function for continuous time:

$J\left(u\right)={\int }_{0}^{\infty }\left\{{z}^{T}Qz+{u}^{T}Ru+2{z}^{T}Nu\right\}dt$

The software computes the gain matrix K by solving an algebraic Riccati equation.

For information about constructing LQ-optimal gain, including the cost function that the software minimizes for discrete time, see the lqi reference page.

#### Constructing the Kalman State Estimator

You need a Kalman state estimator for LQG regulation and servo control because you cannot implement LQ-optimal state feedback without full state measurement.

You construct the state estimate $\stackrel{^}{x}$ such that $u=-K\stackrel{^}{x}$ remains optimal for the output-feedback problem. You construct the Kalman state estimator gain from the following elements:

• State-space plant model sys

• Noise covariance data, Qn, Rn, and Nn

The following figure shows the required dimensions for Qn, Rn, and Nn. If Nn is 0, you can omit it.

Required Dimensions for Qn, Rn, and Nn

### Note

You construct the Kalman state estimator in the same way for both regulation and servo control.

To construct the Kalman state estimator, type the following command:

[kest,L,P] = kalman(sys,Qn,Rn,Nn);

This command computes a Kalman state estimator, kest with the following plant equations:

$\begin{array}{l}\stackrel{˙}{x}=Ax+Bu+Gw\\ y=Cx+Du+Hw+v\end{array}$

where w and v are modeled as white noise. L is the Kalman gain and P the covariance matrix.

The software generates this state estimate using the Kalman filter

$\frac{d}{dt}\stackrel{^}{x}=A\stackrel{^}{x}+Bu+L\left(y-C\stackrel{^}{x}-Du\right)$

with inputs u (controls) and y (measurements). The noise covariance data

$E\left(w{w}^{T}\right)={Q}_{n},\text{ }E\left(v{v}^{T}\right)={R}_{n},\text{ }E\left(w{v}^{T}\right)={N}_{n}$

determines the Kalman gain L through an algebraic Riccati equation.

The Kalman filter is an optimal estimator when dealing with Gaussian white noise. Specifically, it minimizes the asymptotic covariance
$E\left(\left(x-\stackrel{^}{x}\right){\left(x-\stackrel{^}{x}\right)}^{T}\right)$

of the estimation error $x-\stackrel{^}{x}$.

For more information, see the kalman reference page. For a complete example of a Kalman filter implementation, see Kalman Filtering.

#### Forming the LQG Servo Control

To form a two-degree-of-freedom LQG servo controller, connect the Kalman filter kest and LQ-optimal gain K by typing the following command:

servocontroller = lqgtrack(kest, K);
This command forms the LQG servo controller shown in the following figure.

The servo controller has the following state-space equations:

$\begin{array}{l}\left[\begin{array}{c}\stackrel{˙}{\stackrel{^}{x}}\\ {\stackrel{˙}{x}}_{i}\end{array}\right]=\left[\begin{array}{cc}A-B{K}_{x}-LC+LD{K}_{x}& -B{K}_{i}+LD{K}_{i}\\ 0& 0\end{array}\right]\left[\begin{array}{c}\stackrel{^}{x}\\ {x}_{i}\end{array}\right]+\left[\begin{array}{cc}0& L\\ I& -I\end{array}\right]\left[\begin{array}{c}r\\ y\end{array}\right]\\ u=\left[\begin{array}{cc}-{K}_{x}& -{K}_{i}\end{array}\right]\left[\begin{array}{c}\stackrel{^}{x}\\ {x}_{i}\end{array}\right]\end{array}$

For more information on forming LQG servo controllers, including how to form a one-degree-of-freedom LQG servo controller, see the lqgtrack reference page.