# control.matlab.lqr¶

control.matlab.lqr(A, B, Q, R[, N])

The lqr() function computes the optimal state feedback controller u = -K x that minimizes the quadratic cost

The function can be called with either 3, 4, or 5 arguments:

• K, S, E = lqr(sys, Q, R)

• K, S, E = lqr(sys, Q, R, N)

• K, S, E = lqr(A, B, Q, R)

• K, S, E = lqr(A, B, Q, R, N)

where sys is an LTI object, and A, B, Q, R, and N are 2D arrays or matrices of appropriate dimension.

Parameters
• A (2D array_like) – Dynamics and input matrices

• B (2D array_like) – Dynamics and input matrices

• sys (LTI StateSpace system) – Linear system

• Q (2D array) – State and input weight matrices

• R (2D array) – State and input weight matrices

• N (2D array, optional) – Cross weight matrix

• method (str, optional) – Set the method used for computing the result. Current methods are ‘slycot’ and ‘scipy’. If set to None (default), try ‘slycot’ first and then ‘scipy’.

Returns

• K (2D array (or matrix)) – State feedback gains

• S (2D array (or matrix)) – Solution to Riccati equation

• E (1D array) – Eigenvalues of the closed loop system

lqe, dlqr, dlqe

Notes

1. If the first argument is an LTI object, then this object will be used to define the dynamics and input matrices. Furthermore, if the LTI object corresponds to a discrete time system, the dlqr() function will be called.

2. The return type for 2D arrays depends on the default class set for state space operations. See use_numpy_matrix().

Examples

>>> K, S, E = lqr(sys, Q, R, [N])
>>> K, S, E = lqr(A, B, Q, R, [N])