Scilab Function

lqr - LQ compensator (full state)

Calling Sequence

[K,X]=lqr(P12)

Parameters

Description

lqr computes the linear optimal LQ full-state gain for the plant P12=[A,B2,C1,D12] in continuous or discrete time.

P12 is a syslin list (e.g. P12=syslin('c',A,B2,C1,D12)).

The cost function is l2-norm of z'*z with z=C1 x + D12 u i.e. [x,u]' * BigQ * [x;u] where

      [C1' ]               [Q  S]
BigQ= [    ]  * [C1 D12] = [    ]
      [D12']               [S' R]
   

The gain K is such that A + B2*K is stable.

X is the stabilizing solution of the Riccati equation.

For a continuous plant:

(A-B2*inv(R)*S')'*X+X*(A-B2*inv(R)*S')-X*B2*inv(R)*B2'*X+Q-S*inv(R)*S'=0
   
K=-inv(R)*(B2'*X+S)
   

For a discrete plant:

X=A'*X*A-(A'*X*B2+C1'*D12)*pinv(B2'*X*B2+D12'*D12)*(B2'*X*A+D12'*C1)+C1'*C1;
   
K=-pinv(B2'*X*B2+D12'*D12)*(B2'*X*A+D12'*C1)
   

An equivalent form for X is

X=Abar'*inv(inv(X)+B2*inv(r)*B2')*Abar+Qbar
   

with Abar=A-B2*inv(R)*S' and Qbar=Q-S*inv(R)*S'

The 3-blocks matrix pencils associated with these Riccati equations are:

               discrete                           continuous
   |I   0    0|   | A    0    B2|         |I   0   0|   | A    0    B2|
  z|0   A'   0| - |-Q    I    -S|        s|0   I   0| - |-Q   -A'   -S|
   |0   B2'  0|   | S'   0     R|         |0   0   0|   | S'  -B2'   R|
   

Caution: It is assumed that matrix R is non singular. In particular, the plant must be tall (number of outputs >= number of inputs).

Examples

See Also

Author