Main Content

Return measurement residual and residual covariance when using extended or unscented Kalman filter

The `residual`

command returns the difference between the
actual and predicted measurements for `extendedKalmanFilter`

and `unscentedKalmanFilter`

objects. Viewing the residual provides a way for
you to validate the performance of the filter. Residuals, also known as
*innovations*, quantify the prediction error and drive the
correction step in the extended and unscented Kalman filter update sequence. When using
`correct`

and `predict`

(System Identification Toolbox) to update the estimated Kalman filter state, use the
`residual`

command immediately before using the
`correct`

command.

`[`

returns the residual `Residual`

,`ResidualCovariance`

]
= residual(`obj`

,`y`

)`Residual`

between a measurement
`y`

and a predicted measurement produced by the Kalman filter
`obj`

. The function also returns the covariance of the
residual `ResidualCovariance`

.

You create `obj`

using the `extendedKalmanFilter`

or `unscentedKalmanFilter`

commands. You
specify the state transition function *f* and measurement function
*h* of your nonlinear system in `obj`

. The
`State`

property of the object stores the latest estimated
state value. At each time step, you use `correct`

and
`predict`

together to update the state
*x*. The residual *s* is the difference
between the actual and predicted measurements for the time step, and is expressed as
*s* = *y* -
*h*(*x*). The covariance of the residual
*S* is the sum *R* +
*R _{P}*, where

`MeasurementNoise`

property of the filter and Use this syntax if the measurement function *h* that you
specified in `obj.MeasurementFcn`

has one of the following forms:

`y(k) = h(x(k))`

for additive measurement noise`y(k) = h(x(k),v(k))`

for nonadditive measurement noise

Here, `y(k)`

, `x(k)`

, and
`v(k)`

are the measured output, states, and measurement noise
of the system at time step `k`

. The only inputs to
*h* are the states and measurement noise.

`[`

specifies additional input arguments if the measurement function of the system
requires these inputs. You can specify multiple arguments.`Residual`

,`ResidualCovariance`

]
= residual(`obj`

,`y`

,`Um1,...,Umn`

)

Use this syntax if the measurement function *h* has one of the
following forms:

`y(k) = h(x(k),Um1,...,Umn)`

for additive measurement noise`y(k) = h(x(k),v(k),Um1,...,Umn)`

for nonadditive measurement noise

`correct`

| `extendedKalmanFilter`

| `predict`

| `unscentedKalmanFilter`