# DiscreteLQRegulatorGains DiscreteLQRegulatorGains[sspec,wts,τ]

gives the discrete-time state feedback gains with sampling period τ for the continuous-time system specification sspec that minimizes a cost function with weights wts.

DiscreteLQRegulatorGains[,"prop"]

gives the value of the property "prop".

# Details and Options    • DiscreteLQRegulatorGains is also known as discrete linear quadratic regulator, discrete linear quadratic cost equivalent regulator or discrete linear quadratic emulated regulator.
• DiscreteLQRegulatorGains is typically used to compute a digital implementation of a regulating controller or tracking controller.
• A regulating controller aims to maintain the system at an equilibrium state despite disturbances pushing it away. Typical examples include maintaining an inverted pendulum in its upright position or maintaining an aircraft in level flight.
• • The regulating controller is given by a control law of the form , where is the computed gain matrix.
• The approximate discrete-time system: • The continuous-time cost function is given by .
• A tracking controller aims to track a reference signal despite disturbances interfering with it. Typical examples include a cruise control system for a car or path tracking for a robot.
• • The tracking controller is given by a control law of the form , where is the computed gain matrix for the augmented system that includes the system sys as well as the dynamics for .
• • The approximate discrete-time system:
• • The continuous-time cost function is given by , where are the augmented states.
• The number of augmented states is given by , where is given by SystemsModelOrder of sys, the order of yref and the number of signals yref.
• The choice of weighting matrices results in a tradeoff between performance and control effort, and a good design is arrived at iteratively. Their starting values can be diagonal matrices with entries , where zi is the maximum admissible absolute value of the corresponding xi or ui.
• DiscreteLQRegulatorGains computes the discrete-time controller using an approximated discrete-time equivalent of a continuous-time cost function.
• The discrete-time approximated cost function is , with the following terms:
•  state weight matrix input weight matrix cross-coupling weight matrix state vector for regulation and for tracking
• The weights wts can have the following forms:
•  {q,r} cost function with no cross-coupling {q,r,p} cost function with cross-coupling matrix p
• The system specification sspec is the system sys together with the uf, yt and yref specifications.
• The system sys can be given as StateSpaceModel[{a,b,c,d}], where a, b, c and d represent the state, input, output and feed-through matrices in the continuous-time system .
• The discrete-time design model dsys is a zero-order hold approximation with the following terms:
•  state matrix input matrix • The system specification sspec can have the following forms:
•  StateSpaceModel[…] linear control input and linear state AffineStateSpaceModel[…] linear control input and nonlinear state NonlinearStateSpaceModel[…] nonlinear control input and nonlinear state SystemModel[…] general system model <|…|> detailed system specification given as an Association
• The detailed system specification can have the following keys:
•  "InputModel" sys any one of the models "FeedbackInputs" All the feedback inputs uf "TrackedOutputs" None the tracked outpus yt "TrackedSignal" Automatic the dynamics of yref
• The feedback inputs can have the following forms:
•  {num1,…,numn} numbered inputs numi used by StateSpaceModel, AffineStateSpaceModel and NonlinearStateSpaceModel {name1,…,namen} named inputs namei used by SystemModel All uses all inputs
• For nonlinear systems such as AffineStateSpaceModel, NonlinearStateSpaceModel and SystemModel, the system will be linearized around its stored operating point.
• DiscreteLQRegulatorGains[,"Data"] returns a SystemsModelControllerData object cd that can be used to extract additional properties using the form cd["prop"].
• DiscreteLQRegulatorGains[,"prop"] can be used to directly give the value of cd["prop"].
• Possible values for properties "prop" include:
•  "Design" type of controller design "DesignModel" model used for the design "DiscreteTimeClosedLoopPoles" poles of "DiscreteTimeClosedLoopSystem" "DiscreteTimeClosedLoopSystem" dcsys {"DiscreteTimeClosedLoopSystem",cspec} whether to merge the discrete-time closed-loop system "DiscreteTimeControllerModel" dcm "DiscreteTimeDesignModel" approximated discrete-time model dsys "DiscreteTimeOpenLoopPoles" poles of dsys "DiscreteTimeWeights" weights ϕ, ρ, π of the approximated cost "FeedbackGains" gain matrix κ or its equivalent "DiscreteTimeFeedbackGainsModel" dgm or {dgm1,dgm2} "FeedbackInputs" inputs uf of sys used for feedback "InputModel" input model sys "InputsCount" number of inputs u of sys "OpenLoopPoles" poles of "DesignModel" "OutputsCount" number of outputs y of sys "SamplingPeriod" sampling period τ "StatesCount" number of states x of sys "TrackedOutputs" outputs yt of sys that are tracked
• Possible keys for cspec include:
•  "InputModel" input model in csys "Merge" whether to merge csys "ModelName" name of csys
• The diagram of the approximated discrete-time regulator layout.
• The diagram of the approximated discrete-time tracker layout.
• # Examples

open allclose all

## Basic Examples(1)

Compute a set of discrete-time regulator gains for a continuous-time system:

## Scope(27)

### Basic Uses(7)

Compute the discrete-time state feedback gain of a system:

The discrete-time approximation is stable:

The discrete-time closed-loop system is even more stable:

The gain for an unstable system:

The discrete-time approximation is also unstable:

The discrete-time closed-loop system is stable:

The gains for various sampling periods:

The discrete-time approximations:

The discrete-time closed-loop systems:

Compute the state feedback gains for a multiple-state system:

The dimensions of the result correspond to the number of inputs and the system's order:

Compute the gains for a multiple-input system:

Reverse the weights of the feedback inputs:

A higher weight does not lead to a smaller norm:

Increase the weight even more to reduce the relative signal size:

Compute the gains when the cost function contains cross-coupling of the states and feedback inputs:

Compute the gains for a nonlinear system:

The controller for the approximate linear system:

### Plant Models(5)

A descriptor StateSpaceModel:

### Tracking(4)

Design a discrete-time tracking controller:

The closed-loop system tracks the reference signal :

Track multiple outputs:

The closed-loop system tracks two different reference signals:

Compute the controller effort:

The controller model:

The controller inputs:

The controller effort:

Track a desired reference signal:

The reference signal is of order 2:

And a sinusoid:

Design a controller to track one output of a first order system:

The dimensions of the state weighting matrix qq are k+m q:

Compute the controller:

The closed-loop system tracks the reference:

### Properties(11)

DiscreteLQRegulatorGains returns the discrete-time feedback gains by default:

In general, the feedback is affine in the states:

It is of the form κ0+κ1.x, where κ0 and κ1 are constants:

The systems model of the feedback gains:

An affine systems model of the feedback gains:

The discrete-time closed-loop system:

The poles of the linearized closed-loop system:

Increasing the weight of the states makes the system more stable:

Increasing the weight of the feedback inputs makes the system less stable:

The model used to compute the feedback gains:

The poles of the design model:

The discrete-time approximate model used to compute the feedback gains:

The poles of the approximate discrete-time model:

The approximate discrete-time weights:

The design method:

Properties related to the input model:

Get the controller data object:

## Applications(1)

Design an optimal controller by emulation:

The step response of the emulated system:

## Properties & Relations(1)

A continuous-time system:

Compute the weights for the emulated discrete-time system:

Compute the discrete LQ gains using the emulated system and corresponding weights:

DiscreteLQRegulatorGains directly gives the same result:

## Possible Issues(1)

It is not possible to compute an optimal regulator for a system that is not stabilizable: The second mode is not stabilizable: