ControlDesign

 LQRDiscrete
 design discrete-time linear quadratic state feedback regulator (LQR) for a given pair

 Calling Sequence LQRDiscrete(A, B, Q, R, opts)

Parameters

 A - Matrix; system matrix of a state-space system B - Matrix or Vector; input matrix of a state-space system Q - Matrix; state weighting matrix R - Matrix; input weighting matrix opts - (optional) equation(s) of the form option = value; specify options for the LQRDiscrete command

Options

 • N = Matrix or Vector

Weighting on the state-input multiplication term in the cost function. If omitted, a zero matrix with appropriate dimensions will be considered.

 • poles = true or false True means the eigenvalues of A-BK are returned. See LQR for details. The default value is false.
 • riccati = true or false True means the solution of the associated Riccati equation is returned. The infinite horizon solution of the following discrete-time Riccati equation (DARE) is returned.

${A}^{T}\mathrm{XA}-X-\left({A}^{T}\mathrm{XB}+N\right){\left({B}^{T}\mathrm{XB}+R\right)}^{-1}\left({B}^{T}\mathrm{XA}+{N}^{T}\right)+Q=0$

The LQR feedback gain is calculated as

$K={\left({B}^{T}\mathrm{XB}+R\right)}^{-1}\left({B}^{T}\mathrm{XA}+{N}^{T}\right)$

The default value is false.

 • parameters = {list, set}(name = complexcons)
 Specifies numeric values for the parameters of sys. These values override any parameters previously specified for sys. The numeric value on the right-hand side of each equation is substituted for the name on the left-hand side in the sys equations. The default is the value of sys given by DynamicSystems:-SystemOptions(parameters).

Solvability Conditions

 • The pair $\left(A,B\right)$ must be stabilizable.
 • The pair $\left(Q-N{R}^{-1}{N}^{T},A-B{R}^{-1}{N}^{T}\right)$ must have no unobservable modes on the unit circle.
 • $R>0$ (positive definite) and $Q-N{R}^{-1}{N}^{T}\ge 0$ (positive semidefinite).

Description

 • The LQRDiscrete command calculates the discrete-time LQR state feedback gain for a given pair.
 • The optimal state feedback gain, $K$, is calculated such that the quadratic cost function

$J\left(u\right)=\sum _{n=0}^{\infty }\left({x}^{T}\mathrm{Qx}+{u}^{T}\mathrm{Ru}+2{x}^{T}\mathrm{Νu}\right)$

is minimized by the feedback law u[n] = -Kx[n] subject to the system dynamics

$x\left[n+1\right]=\mathrm{Ax}\left[n\right]+\mathrm{Bu}\left[n\right]$

 • Q and R are expected to be symmetric. If the input Q and/or R are not symmetric, their symmetric part will be considered since their antisymmetric (skew-symmetric) part has no role in the quadratic cost function.
 • In addition to the state feedback gain, depending on the corresponding option values, the command also returns the closed-loop eigenvalues and the solution of the associated Riccati equation.
 • Note that the time domain is inherent to the command regardless of the any time domain implications the input pair might have. To be more specific, this command calculates a discrete-time LQR feedback gain for the given input pair even if that pair is initially extracted from a continuous-time state-space. If the gain is then used for feedback stabilization in continuous time domain, obviously such a mistake in command usage leads to a result which is not theoretically valid.

Examples

 > $\mathrm{with}\left(\mathrm{ControlDesign}\right):$
 > $\mathrm{with}\left(\mathrm{DynamicSystems}\right):$
 > $\mathrm{csys}≔\mathrm{NewSystem}\left(\mathrm{Matrix}\left(\left[\left[\frac{2}{{s}^{2}+3s+1},\frac{1}{s+2}\right],\left[\frac{s-1}{{s}^{2}+5},\frac{7}{\left(s+1\right)\left(s+4\right)}\right]\right]\right)\right)$
 ${\mathrm{csys}}{≔}\left[\begin{array}{c}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{2 output\left(s\right); 2 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({s}\right){,}{\mathrm{u2}}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({s}\right){,}{\mathrm{y2}}{}\left({s}\right)\right]\end{array}\right$ (1)
 > $\mathrm{sys}≔\mathrm{StateSpace}\left(\mathrm{csys}\right)$
 ${\mathrm{sys}}{≔}\left[\begin{array}{c}{\mathbf{State Space}}\\ {\mathrm{continuous}}\\ {\mathrm{2 output\left(s\right); 2 input\left(s\right); 7 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({t}\right){,}{\mathrm{u2}}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({t}\right){,}{\mathrm{y2}}{}\left({t}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1}}{}\left({t}\right){,}{\mathrm{x2}}{}\left({t}\right){,}{\mathrm{x3}}{}\left({t}\right){,}{\mathrm{x4}}{}\left({t}\right){,}{\mathrm{x5}}{}\left({t}\right){,}{\mathrm{x6}}{}\left({t}\right){,}{\mathrm{x7}}{}\left({t}\right)\right]\end{array}\right$ (2)
 > $\mathrm{sys}:-a;$$\mathrm{sys}:-b;$$\mathrm{sys}:-c;$$\mathrm{sys}:-d$
 $\left[\begin{array}{ccccccc}{0}& {1}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {1}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {1}& {0}& {0}& {0}\\ {-5}& {-15}& {-6}& {-3}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {1}\\ {0}& {0}& {0}& {0}& {-8}& {-14}& {-7}\end{array}\right]$
 $\left[\begin{array}{cc}{0}& {0}\\ {0}& {0}\\ {0}& {0}\\ {1}& {0}\\ {0}& {0}\\ {0}& {0}\\ {0}& {1}\end{array}\right]$
 $\left[\begin{array}{ccccccc}{10}& {0}& {2}& {0}& {4}& {5}& {1}\\ {-1}& {-2}& {2}& {1}& {14}& {7}& {0}\end{array}\right]$
 $\left[\begin{array}{cc}{0}& {0}\\ {0}& {0}\end{array}\right]$ (3)
 > $Q≔\frac{1}{3}\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(7\right);$$R≔2\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(2\right)$
 ${Q}{≔}\left[\begin{array}{ccccccc}\frac{{1}}{{3}}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& \frac{{1}}{{3}}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& \frac{{1}}{{3}}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& \frac{{1}}{{3}}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& \frac{{1}}{{3}}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& \frac{{1}}{{3}}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& \frac{{1}}{{3}}\end{array}\right]$
 ${R}{≔}\left[\begin{array}{cc}{2}& {0}\\ {0}& {2}\end{array}\right]$ (4)
 > $\mathrm{dsys}≔\mathrm{ToDiscrete}\left(\mathrm{csys},1,\mathrm{method}=\mathrm{bilinear}\right)$
 ${\mathrm{dsys}}{≔}\left[\begin{array}{c}{\mathbf{Transfer Function}}\\ {\mathrm{discrete; sampletime = 1}}\\ {\mathrm{2 output\left(s\right); 2 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({z}\right){,}{\mathrm{u2}}{}\left({z}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({z}\right){,}{\mathrm{y2}}{}\left({z}\right)\right]\end{array}\right$ (5)
 > $\mathrm{sys}≔\mathrm{StateSpace}\left(\mathrm{dsys}\right)$
 ${\mathrm{sys}}{≔}\left[\begin{array}{c}{\mathbf{State Space}}\\ {\mathrm{discrete; sampletime = 1}}\\ {\mathrm{2 output\left(s\right); 2 input\left(s\right); 7 state\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({q}\right){,}{\mathrm{u2}}{}\left({q}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({q}\right){,}{\mathrm{y2}}{}\left({q}\right)\right]\\ {\mathrm{statevariable}}{=}\left[{\mathrm{x1}}{}\left({q}\right){,}{\mathrm{x2}}{}\left({q}\right){,}{\mathrm{x3}}{}\left({q}\right){,}{\mathrm{x4}}{}\left({q}\right){,}{\mathrm{x5}}{}\left({q}\right){,}{\mathrm{x6}}{}\left({q}\right){,}{\mathrm{x7}}{}\left({q}\right)\right]\end{array}\right$ (6)
 > $K≔\mathrm{LQRDiscrete}\left(\mathrm{sys}:-a,\mathrm{sys}:-b,Q,R\right)$
 ${K}{≔}\left[\begin{array}{ccccccc}{0.0481202313583566}& {0.301603484258431}& {-0.420834895319010}& {0.0511514301846526}& {0.}& {0.}& {0.}\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.0372408140738923}& {2.04657437887789}{×}{{10}}^{{-50}}\end{array}\right]$ (7)
 > $\mathrm{Kpr}≔\mathrm{LQRDiscrete}\left(\mathrm{sys}:-a,\mathrm{sys}:-b,Q,R,\mathrm{poles}=\mathrm{true},\mathrm{riccati}=\mathrm{true}\right):$$\mathrm{Kpr}\left[1\right];$$\mathrm{Kpr}\left[2\right];$$\mathrm{Kpr}\left[3\right]$
 $\left[\begin{array}{ccccccc}{0.0481202313583566}& {0.301603484258431}& {-0.420834895319010}& {0.0511514301846526}& {0.}& {0.}& {0.}\\ {0.}& {0.}& {0.}& {0.}& {0.}& {0.0372408140738923}& {2.04657437887789}{×}{{10}}^{{-50}}\end{array}\right]$
 $\left[\begin{array}{c}{-0.0959924471219731}{+}{0.725780367562653}{}{I}\\ {-0.0959924471219731}{-}{0.725780367562653}{}{I}\\ {0.597646681572766}{+}{0.}{}{I}\\ {-0.133580894281149}{+}{0.}{}{I}\\ {0.}{+}{0.}{}{I}\\ {0.271790906833210}{+}{0.}{}{I}\\ {-0.271790906833210}{+}{0.}{}{I}\end{array}\right]$
 $\left[\begin{array}{ccccccc}{0.34208246630757997956980029649788563935178633568755}& {0.054836997137896559065463795059790315059092605697878}& {-0.076515435512547225295424098079403393811628194830151}& {0.0093002600335731939690014549517222339482644436265516}& {0.}& {0.}& {0.}\\ {0.054836997137896559065463795059790315059092605697878}& {1.0190795441519386008663204999259911522050659569203}& {-0.42467264969582701414729333026735701324346677591194}& {-0.016116727803692753085068460478712194235728673634451}& {0.}& {0.}& {0.}\\ {-0.076515435512547225295424098079403393811628194830151}& {-0.42467264969582701414729333026735701324346677591194}& {2.0214621984357416787319413739918552066383416590039}& {-0.50965995701396297664230311502896433392582286601365}& {0.}& {0.}& {0.}\\ {0.0093002600335731939690014549517222339482644436265516}& {-0.016116727803692753085068460478712194235728673634451}& {-0.50965995701396297664230311502896433392582286601365}& {2.2491943867445609900304786951080077626858922247949}& {0.}& {0.}& {0.}\\ {0.}& {0.}& {0.}& {0.}& {0.33333333333333333333333333333333333333333333333333}& {2.2865039209104185372543140058046721769304597671473}{×}{{10}}^{{-50}}& {2.8675502202583078721736253812994957905085589515221}{×}{{10}}^{{-50}}\\ {0.}& {0.}& {0.}& {0.}& {2.2865039209104185372543140058046721769304597671473}{×}{{10}}^{{-50}}& {0.67494240312753162573746634389760125687054612602570}& {6.1566600468408239873788918398523229241598769169614}{×}{{10}}^{{-50}}\\ {0.}& {0.}& {0.}& {0.}& {2.8675502202583078721736253812994957905085589515221}{×}{{10}}^{{-50}}& {6.1566600468408239873788918398523229241598769169614}{×}{{10}}^{{-50}}& {1.0082757364608649590707996772309345902038794593591}\end{array}\right]$ (8)