lqr [control]
— Function File: [k, p, e] = lqr (a, b, q, r, z)

construct the linear quadratic regulator for the continuous time system

          dx
          -- = A x + B u
          dt

to minimize the cost functional

          infinity
          /
          J = |  x' Q x + u' R u
          /
          t=0

z omitted or

          infinity
          /
          J = |  x' Q x + u' R u + 2 x' Z u
          /
          t=0

z included.

The following values are returned:

k
The state feedback gain, (a - bk) is stable and minimizes the cost functional
p
The stabilizing solution of appropriate algebraic Riccati equation.
e
The vector of the closed loop poles of (a - bk).

Reference Anderson and Moore, Optimal control: linear quadratic methods, Prentice-Hall, 1990, pp. 56–58.