# ControlSystems: dlqr method

**URL:** https://discourse.julialang.org/t/controlsystems-dlqr-method/15217
**Category:** Modelling & Simulations
**Tags:** control
**Created:** [September 20, 2018, 7:15am UTC](https://discourse.julialang.org/t/controlsystems-dlqr-method/15217 "2018-09-20T07:15:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [September 20, 2018, 7:15am UTC](https://discourse.julialang.org/t/controlsystems-dlqr-method/15217/1 "2018-09-20T07:15:20Z")

</div>

I’m a little confused by the “`docstring`”/documentation of `dlqr`:

```nohighlight
  dlqr(A, B, Q, R), dlqr(sys, Q, R)

  Calculate the optimal gain matrix K for the state-feedback law u[k] = K*x[k] that minimizes the cost function:

  J = sum(x'Qx + u'Ru, 0, inf).

  For the discrte time model x[k+1] = Ax[k] + Bu[k].

  See also lqg

  Usage example:

  h = 0.1
  A = [1 h; 0 1]
  B = [0;1]
  C = [1 0]
  sys = ss(A,B,C,0, h)
  Q = eye(2)
  R = eye(1)
  L = dlqr(A,B,Q,R) # lqr(sys,Q,R) can also be used

  u(t,x) = -L*x # Form control law,

```

The introduction talks about computing matrix `K` and positive feedback u=Kx while the example states that matrix `L` is computed where presumably L=-K.

I assume this is just a question of typos/documentation in need of update?

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [September 20, 2018, 7:47am UTC](https://discourse.julialang.org/t/controlsystems-dlqr-method/15217/2 "2018-09-20T07:47:10Z")

</div>

Correct
