ControlDesign

 LQROutput
 design linear quadratic state feedback regulator (LQR) with output weighting

 Calling Sequence LQROutput(sys, Q, R, opts)

Parameters

 sys - System; system object Q - Matrix; output weighting matrix R - Matrix; input weighting matrix opts - (optional) equation(s) of the form option = value; specify options for the LQROutput command

Options

 • N = Matrix or Vector

Weighting on the output-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 default value is false.
 • return_Kr  =  true or false True means the direct gain Kr is returned. 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 data $A,B,\stackrel{_}{Q},\stackrel{_}{R},\stackrel{_}{N}$ must satisfy the solvability conditions of the standard LQR problem described in the LQR help page.

Description

 • The LQROutput command calculates the LQR state feedback gain for a system with output weighting.
 • The system sys is a continuous or discrete-time linear system object created using the DynamicSystems package. The system object must be in state-space (SS) form.
 • In continuous-time domain, the optimal state feedback gain, $K$, is calculated such that the quadratic cost-function

$J\left(u\right)={\int }_{0}^{\infty }\left({y}^{T}\mathrm{Qy}+{u}^{T}\mathrm{Ru}+2{y}^{T}\mathrm{Νu}\right)ⅆt$

is minimized by the feedback law u = -Kx subject to the following state-space

$\stackrel{·}{x}=\mathrm{Ax}+\mathrm{Bu}$

$y=\mathrm{Cx}+\mathrm{Du}$

 • In discrete-time domain, the optimal state feedback gain, $K$, is calculated such that the quadratic cost-function

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

is minimized by the feedback law u[n] = -Kx[n] subject to the following state-space

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

$y\left[n\right]=\mathrm{Cx}\left[n\right]+\mathrm{Du}\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 LQR with output weighting, the weighting matrix Q acts on the outputs rather than the states as in the standard LQR. Also, the weighing matrix N acts on the inner product of the outputs and inputs (creating a bilinear form) rather than the inner product of the states and inputs.
 • In addition to the state feedback gain, depending on the corresponding option values, the command returns the closed-loop eigenvalues and the solution of the associated Riccati equation.
 • The output weighting LQR problem is equivalent to the standard LQR problem with the following weighting matrices:

$\stackrel{_}{Q}={C}^{T}\mathrm{QC}$

$\stackrel{_}{R}={\mathrm{D}}^{T}\left(\mathrm{QD}+N\right)+{N}^{T}\mathrm{D}+R$

$\stackrel{_}{N}={C}^{T}\left(\mathrm{QD}+N\right)$

 • The direct gain Kr is computed as follows:

$\left(C-\mathrm{D}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}K\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\left(\frac{1}{-A+B\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}K}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}B+\mathrm{D}$

$\left(C-\mathrm{D}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}K\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\left(\frac{1}{-A+I+B\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}K}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}B+\mathrm{D}$ (discrete time)

 • If sys contains structured uncontrollable or unobservable states, they are removed using ReduceSystem before computing the LQR state feedback.  The resulting gain $K$ is then filled with zeros at positions corresponding to the removed states; however, the other outputs are not filled and, consequently, they may have lower dimensions as expected.

Examples

 > $\mathrm{with}\left(\mathrm{ControlDesign}\right):$
 > $\mathrm{with}\left(\mathrm{DynamicSystems}\right):$
 > $\mathrm{csys}≔\mathrm{NewSystem}\left(\mathrm{Matrix}\left(\left[\left[\frac{3}{\left(s+2\right)\left(s+7\right)},\frac{1}{s+1}\right],\left[\frac{3s-2}{{s}^{2}+5},\frac{1}{{s}^{2}+5s+1}\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{csys}:-\mathrm{tf}$
 $\left[\begin{array}{cc}\frac{{3}}{{{s}}^{{2}}{+}{9}{}{s}{+}{14}}& \frac{{1}}{{s}{+}{1}}\\ \frac{{3}{}{s}{-}{2}}{{{s}}^{{2}}{+}{5}}& \frac{{1}}{{{s}}^{{2}}{+}{5}{}{s}{+}{1}}\end{array}\right]$ (2)
 > $\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$ (3)
 > $\mathrm{sys}:-a;$$\mathrm{sys}:-b;$$\mathrm{sys}:-c;$$\mathrm{sys}:-d$
 $\left[\begin{array}{rrrrrrr}{0}& {1}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {1}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {1}& {0}& {0}& {0}\\ {-}{70}& {-}{45}& {-}{19}& {-}{9}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {1}\\ {0}& {0}& {0}& {0}& {-}{1}& {-}{6}& {-}{6}\end{array}\right]$
 $\left[\begin{array}{rr}{0}& {0}\\ {0}& {0}\\ {0}& {0}\\ {1}& {0}\\ {0}& {0}\\ {0}& {0}\\ {0}& {1}\end{array}\right]$
 $\left[\begin{array}{rrrrrrr}{15}& {0}& {3}& {0}& {1}& {5}& {1}\\ {-}{28}& {24}& {25}& {3}& {1}& {1}& {0}\end{array}\right]$
 $\left[\begin{array}{rr}{0}& {0}\\ {0}& {0}\end{array}\right]$ (4)
 > $Q≔\frac{1\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(2\right)}{5};$$R≔2\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(2\right)$
 ${Q}{≔}\left[\begin{array}{cc}\frac{{1}}{{5}}& {0}\\ {0}& \frac{{1}}{{5}}\end{array}\right]$
 ${R}{≔}\left[\begin{array}{rr}{2}& {0}\\ {0}& {2}\end{array}\right]$ (5)
 > $K≔\mathrm{LQROutput}\left(\mathrm{sys},Q,R\right)$
 ${K}{≔}\left[\begin{array}{ccccccc}{0.717034668157443}& {14.2423392627583}& {8.97325040212257}& {0.992321630768280}& {-}{0.0178914427159702}& {0.0116054056366964}& {-}{0.00303834255501862}\\ {-}{0.0317449620940457}& {-}{0.565427777675089}& {-}{0.0603711482280991}& {-}{0.00303834255501862}& {0.0952989985741524}& {0.298425245845240}& {0.0577917808525738}\end{array}\right]$ (6)
 > $\mathrm{Kpr}≔\mathrm{LQROutput}\left(\mathrm{sys},Q,R,\mathrm{poles}=\mathrm{true},\mathrm{riccati}=\mathrm{true},\mathrm{return_Kr}=\mathrm{true}\right):$${\mathrm{Kpr}}_{1};$${\mathrm{Kpr}}_{2};$${\mathrm{Kpr}}_{3};$${\mathrm{Kpr}}_{4}$
 $\left[\begin{array}{ccccccc}{0.717034668157443}& {14.2423392627583}& {8.97325040212257}& {0.992321630768280}& {-}{0.0178914427159702}& {0.0116054056366964}& {-}{0.00303834255501862}\\ {-}{0.0317449620940457}& {-}{0.565427777675089}& {-}{0.0603711482280991}& {-}{0.00303834255501862}& {0.0952989985741524}& {0.298425245845240}& {0.0577917808525738}\end{array}\right]$
 $\left[\begin{array}{c}{-}{6.99856378303373}{+}{0.}{}{I}\\ {-}{4.79073410146029}{+}{0.}{}{I}\\ {-}{0.494228759193812}{+}{2.18968411573883}{}{I}\\ {-}{0.494228759193812}{-}{2.18968411573883}{}{I}\\ {-}{2.00557177848028}{+}{0.}{}{I}\\ {-}{1.04883795460929}{+}{0.}{}{I}\\ {-}{0.217948275649673}{+}{0.}{}{I}\end{array}\right]$
 $\left[\begin{array}{ccccccc}{2213.3210179011925105661490359729988635623523105777}& {1427.3744698955260840335662780084477714201028438168}& {170.05490326097842788563325766245079711056354077698}& {1.4340693363148856210209140521689160116840515800739}& {-}{8.1584867958664927190611477199891984007760389352564}& {-}{3.8143338925075523792756023597033096286517352171425}& {-}{0.063489924188091382049176469030954150915142789638243}\\ {1427.3744698955260840335662780084477714201028438168}& {1314.4149489966517127605774990095472393845261805749}& {358.10638273538894791100970655990292973259306704383}& {28.484678525516698881224832846966240322944663907424}& {-}{6.7332125306921498463443365378844628598517488954127}& {-}{7.1469946052254660167289986202242491609016370025761}& {-}{1.1308555553501777075201057104844140218420156581446}\\ {170.05490326097842788563325766245079711056354077698}& {358.10638273538894791100970655990292973259306704383}& {173.55111848299452019907894155637818079428896173084}& {17.946500804245141593919755909088874368587080074509}& {-}{0.96420988722855540330309373855482549187031417311249}& {-}{0.37056076992136628982081706414090368560463357756919}& {-}{0.12074229645619825350879543233467955529836974169035}\\ {1.4340693363148856210209140521689160116840515800739}& {28.484678525516698881224832846966240322944663907424}& {17.946500804245141593919755909088874368587080074509}& {1.9846432615365601333495110097986200526978925133139}& {-}{0.035782885431940392539024834988131723694174424070744}& {0.023210811273392858470564369426083998560166901460873}& {-}{0.0060766851100372365759906089897292226102991059271909}\\ {-}{8.1584867958664927190611477199891984007760389352564}& {-}{6.7332125306921498463443365378844628598517488954127}& {-}{0.96420988722855540330309373855482549187031417311249}& {-}{0.035782885431940392539024834988131723694174424070744}& {0.59690245383661254959345476298732008112992241926137}& {1.0702952629406602870546063132728061843987429911545}& {0.19059799714830485098021287040917562854135390550258}\\ {-}{3.8143338925075523792756023597033096286517352171425}& {-}{7.1469946052254660167289986202242491609016370025761}& {-}{0.37056076992136628982081706414090368560463357756919}& {0.023210811273392858470564369426083998560166901460873}& {1.0702952629406602870546063132728061843987429911545}& {3.1184288536473559060855917389389997225292005817800}& {0.59685049169047937887974968854007127189693335562395}\\ {-}{0.063489924188091382049176469030954150915142789638243}& {-}{1.1308555553501777075201057104844140218420156581446}& {-}{0.12074229645619825350879543233467955529836974169035}& {-}{0.0060766851100372365759906089897292226102991059271909}& {0.19059799714830485098021287040917562854135390550258}& {0.59685049169047937887974968854007127189693335562395}& {0.11558356170514763732723892618907256020381429737325}\end{array}\right]$
 $\left[\begin{array}{cc}{1.63293195981652}& {-}{1.65082340253249}\\ {0.712479697627494}& {0.382819300946659}\end{array}\right]$ (7)

We can also use LQROuput with discrete models:

 > $\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$ (8)
 > $\mathrm{dsys}:-\mathrm{tf}$
 $\left[\begin{array}{cc}\frac{{3}}{{4}}{}\frac{{\left({z}{+}{1}\right)}^{{2}}}{\left({9}{}{z}{+}{5}\right){}{z}}& \frac{{1}}{{3}}{}\frac{{z}{+}{1}}{{z}{-}\frac{{1}}{{3}}}\\ \frac{{4}}{{9}}{}\frac{\left({z}{+}{1}\right){}\left({z}{-}{2}\right)}{{{z}}^{{2}}{+}\frac{{2}}{{9}}{}{z}{+}{1}}& \frac{{1}}{{15}}{}\frac{{\left({z}{+}{1}\right)}^{{2}}}{{{z}}^{{2}}{-}\frac{{2}}{{5}}{}{z}{-}\frac{{1}}{{3}}}\end{array}\right]$ (9)
 > $\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$ (10)
 > $Q≔5\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(2\right);$$R≔3\mathrm{LinearAlgebra}:-\mathrm{IdentityMatrix}\left(2\right)$
 ${Q}{≔}\left[\begin{array}{rr}{5}& {0}\\ {0}& {5}\end{array}\right]$
 ${R}{≔}\left[\begin{array}{rr}{3}& {0}\\ {0}& {3}\end{array}\right]$ (11)
 > $K≔\mathrm{LQROutput}\left(\mathrm{sys},Q,R\right)$
 ${K}{≔}\left[\begin{array}{ccccccc}{0.00356160133647377}& {-}{0.494191307766542}& {-}{0.914892355689041}& {-}{0.0264403506039962}& {-}{0.00753844597397812}& {-}{0.0102161879672920}& {-}{0.00237235112808720}\\ {0.0300774217423282}& {0.0656631598525158}& {-}{0.00165075351937600}& {-}{0.0578915850030273}& {-}{0.0812015931703188}& {-}{0.0812549022768781}& {0.279310675111098}\end{array}\right]$ (12)
 > $\mathrm{Kpr}≔\mathrm{LQROutput}\left(\mathrm{sys},Q,R,\mathrm{poles}=\mathrm{true},\mathrm{riccati}=\mathrm{true},\mathrm{return_Kr}=\mathrm{true}\right):$${\mathrm{Kpr}}_{1};$${\mathrm{Kpr}}_{2};$${\mathrm{Kpr}}_{3};$${\mathrm{Kpr}}_{4}$
 $\left[\begin{array}{ccccccc}{0.00356160133647377}& {-}{0.494191307766542}& {-}{0.914892355689041}& {-}{0.0264403506039962}& {-}{0.00753844597397812}& {-}{0.0102161879672920}& {-}{0.00237235112808720}\\ {0.0300774217423282}& {0.0656631598525158}& {-}{0.00165075351937600}& {-}{0.0578915850030273}& {-}{0.0812015931703188}& {-}{0.0812549022768781}& {0.279310675111098}\end{array}\right]$
 $\left[\begin{array}{c}{0.767828122439181}{+}{0.}{}{I}\\ {0.146877156240929}{+}{0.}{}{I}\\ {-}{0.0598533454582571}{+}{0.309176357637630}{}{I}\\ {-}{0.0598533454582571}{-}{0.309176357637630}{}{I}\\ {-}{0.132589590854146}{+}{0.}{}{I}\\ {-}{0.554251178458365}{+}{0.}{}{I}\\ {-}{0.405472587458189}{+}{0.}{}{I}\end{array}\right]$
 $\left[\begin{array}{ccccccc}{0.030421135822715746661483119465619750780079644226519}& {0.065909907466081445943651725217081837731677484888381}& {0.077863993891928202554012314536566316895231948722372}& {0.059112886634046876785210492949616537395421761897085}& {-}{0.050188644413976545817420078367331778312895021111404}& {-}{0.062433942231198913457006717445770242913882168709431}& {0.14647440916725792764105957938065613949658264398518}\\ {0.065909907466081445943651725217081837731677484888381}& {2.2847701972316684633140332644560369698375292274017}& {4.7847306516135635638601767892353674998604105167075}& {1.5200731282028195434731344834060459690437415027044}& {-}{0.051381185070926621076018021910551508907205422423887}& {-}{0.24248117228076022252788740320992280262529833198557}& {-}{0.018026465186631385616928025593331378129935273493821}\\ {0.077863993891928202554012314536566316895231948722372}& {4.7847306516135635638601767892353674998604105167075}& {12.217596587591310011803119523701421197584453334801}& {6.8714533828437224847228249708724585749274573728353}& {0.033219117439838470818425867947158666956219639899675}& {-}{0.41757515631223804555176954389437678658213715588195}& {-}{0.68989774217826862624169968848499880789368219782819}\\ {0.059112886634046876785210492949616537395421761897085}& {1.5200731282028195434731344834060459690437415027044}& {6.8714533828437224847228249708724585749274573728353}& {7.7290189303281432825264402037496282033620051084464}& {-}{0.00089785711277865282387993604941083466168087624032189}& {-}{0.25047345435813408835915911397628042401730449430088}& {-}{0.52414391617243365970614715171054243008109996218594}\\ {-}{0.050188644413976545817420078367331778312895021111404}& {-}{0.051381185070926621076018021910551508907205422423887}& {0.033219117439838470818425867947158666956219639899675}& {-}{0.00089785711277865282387993604941083466168087624032189}& {0.096303809125238661441515557835814164660578301981060}& {0.10527321517532861157297605229965868726473800562174}& {-}{0.30422873354722336756437043493817780506351359200722}\\ {-}{0.062433942231198913457006717445770242913882168709431}& {-}{0.24248117228076022252788740320992280262529833198557}& {-}{0.41757515631223804555176954389437678658213715588195}& {-}{0.25047345435813408835915911397628042401730449430088}& {0.10527321517532861157297605229965868726473800562174}& {0.15017244479508106184875357307589186761301102349660}& {-}{0.27910155202740406405198625921281687752114303705794}\\ {0.14647440916725792764105957938065613949658264398518}& {-}{0.018026465186631385616928025593331378129935273493821}& {-}{0.68989774217826862624169968848499880789368219782819}& {-}{0.52414391617243365970614715171054243008109996218594}& {-}{0.30422873354722336756437043493817780506351359200722}& {-}{0.27910155202740406405198625921281687752114303705794}& {1.0680116872765628785913505609708284332160101080345}\end{array}\right]$
 $\left[\begin{array}{cc}{0.879831651067362}& {-}{0.993045941963838}\\ {1.09622204012740}& {0.561082720692690}\end{array}\right]$ (13)