dkalman [control]
— Function File: [Lp, Lf, P, Z] = dkalman (A, G, C, Qw, Rv, S)

Construct the linear quadratic estimator (Kalman predictor) for the discrete time system

          x[k+1] = A x[k] + B u[k] + G w[k]
          y[k] = C x[k] + D u[k] + v[k]

where w, v are zero-mean gaussian noise processes with respective intensities Qw = cov (w, w) and Rv = cov (v, v).

If specified, S is cov (w, v). Otherwise cov (w, v) = 0.

The observer structure is

          x[k+1|k] = A x[k|k-1] + B u[k] + LP (y[k] - C x[k|k-1] - D u[k])
          x[k|k] = x[k|k-1] + LF (y[k] - C x[k|k-1] - D u[k])

The following values are returned:

Lp
The predictor gain, (A - Lp C) is stable.
Lf
The filter gain.
P
The Riccati solution.

P = E [(x - x[n|n-1])(x - x[n|n-1])']

Z
The updated error covariance matrix.

Z = E [(x - x[n|n])(x - x[n|n])']