Main Content

Design Kalman filter for state estimation

`[`

creates a Kalman filter given the plant model `kalmf`

,`L`

,`P`

] = kalman(`sys`

,`Q`

,`R`

,`N`

)`sys`

and the noise
covariance data `Q`

, `R`

, and `N`

.
The function computes a Kalman filter for use in a Kalman estimator with the configuration
shown in the following diagram.

You construct the model `sys`

with known inputs *u*
and white process noise inputs *w*, such that *w* consists
of the last *N _{w}* inputs to

`sys`

.
The "true" plant output `sys`

. You also provide the noise covariance data
`Q`

, `R`

, and `N`

. The returned
Kalman filter `kalmf`

is a state-space model that takes the known inputs
`kalman`

also returns the Kalman
gains `L`

and the steady-state error covariance matrix
`P`

. `[`

computes a Kalman filter when one or both of the following conditions exist.`kalmf`

,`L`

,`P`

] = kalman(`sys`

,`Q`

,`R`

,`N`

,`sensors`

,`known`

)

Not all outputs of

`sys`

are measured.The disturbance inputs

*w*are not the last inputs of`sys`

.

The index vector `sensors`

specifies which outputs of
`sys`

are measured. These outputs make up *y*. The
index vector `known`

specifies which inputs are known (deterministic).
The known inputs make up *u*. The `kalman`

command takes
the remaining inputs of `sys`

to be the stochastic inputs
*w*.

`[`

specifies the estimator type for a discrete-time `kalmf`

,`L`

,`P`

,`Mx`

,`Z`

,`My`

] = kalman(___,`type`

)`sys`

.

`type = 'current'`

— Compute output estimates $$\widehat{y}[n|n]$$ and state estimates $$\widehat{x}[n|n]$$ using all available measurements up to $$y[n]$$.`type = 'delayed'`

— Compute output estimates $$\widehat{y}[n|n-1]$$ and state estimates $$\widehat{x}[n|n-1]$$ using measurements only up to $$y\left[n-1\right]$$. The delayed estimator is easier to implement inside control loops.

You can use the `type`

input argument with any of the
previous input argument combinations.

The plant and noise data must satisfy:

(

*C*,*A*) is detectable, where:$$\overline{R}>0$$ and $$\left[\begin{array}{cc}\overline{Q}& \overline{N};\text{\hspace{0.17em}}\text{\hspace{0.17em}}\begin{array}{cc}{\overline{N}}^{\prime}& \overline{R}\end{array}\end{array}\right]\ge 0$$, where

$$\left[\begin{array}{cc}\overline{Q}& \overline{N}\\ {\overline{N}}^{\prime}& \overline{R}\end{array}\right]=\left[\begin{array}{cc}G& 0\\ H& I\end{array}\right]\left[\begin{array}{cc}Q& N\\ {N}^{\prime}& R\end{array}\right]{\left[\begin{array}{cc}G& 0\\ H& I\end{array}\right]}^{\prime}.$$

$$(A-\overline{N}{\overline{R}}^{-1}C,\overline{Q}-\overline{N}{\overline{R}}^{-1}{\overline{N}}^{T})$$ has no uncontrollable mode on the imaginary axis in continuous time, or on the unit circle in discrete time.