Documentation

# trackingEKF class

Extended Kalman filter

## Description

The `trackingEKF` class creates a discrete-time extended Kalman filter used for tracking positions and velocities of target platforms. A Kalman filter is a recursive algorithm for estimating the evolving state of a process when measurements are made on the process. The extended Kalman filter can model the evolution of a state that follows a nonlinear motion model, or when the measurements are nonlinear functions of the state, or both. The filter also allows for optional controls or forces to act on the object. The extended Kalman filter is based on the linearization of the nonlinear equations. This approach leads to a filter formulation similar to the linear Kalman filter, `trackingKF`.

The process and the measurements can have Gaussian noise which can be included in two ways:

• Noise can be added to both the process and the measurements. In this case, the sizes of the process noise and measurement noise must match the sizes of the state vector and measurement vector, respectively.

• Noises can be included in the state transition function, the measurement model function, or both. In these cases, the corresponding noise sizes are not restricted.

## Construction

`filter = trackingEKF` creates an extended Kalman filter object for a discrete-time system using default values for the `StateTransitionFcn`, `MeasurementFcn`, and `State` properties. The process and measurement noises are assumed to be additive.

`filter = trackingEKF(transitionfcn,measurementfcn,state)` specifies the state transition function, `transitionfcn`, the measurement function, `measurementfcn`, and the initial state of the system, `state`.

`filter = trackingEKF(___,Name,Value)` configures the properties of the extended Kalman filter object using one or more `Name,Value` pair arguments. Any unspecified properties have default values.

## Properties

expand all

Kalman filter state, specified as a real-valued M-element vector.

Example: `[200;0.2]`

Data Types: `double`

State error covariance, specified as a positive-definite real-valued M-by-M matrix where M is the size of the filter state. The covariance matrix represents the uncertainty in the filter state.

Example: `[20 0.1; 0.1 1]`

State transition function, specified as a function handle. This function calculates the state vector at time step k from the state vector at time step k–1. The function can take additional input parameters, such as control inputs or time step size. The function can also include noise values.

• If `HasAdditiveProcessNoise` is `true`, specify the function using one of these syntaxes:

```x(k) = transitionfcn(x(k-1)) ```
`x(k) = transitionfcn(x(k-1),parameters)`
where `x(k)` is the state at time `k`. The `parameters` term stands for all additional arguments required by the state transition function.

• If `HasAdditiveProcessNoise` is `false`, specify the function using one of these syntaxes:

```x(k) = transitionfcn(x(k-1),w(k-1)) ```
`x(k) = transitionfcn(x(k-1),w(k-1),parameters)`
where `x(k)` is the state at time `k` and `w(k)` is a value for the process noise at time `k`. The `parameters` argument stands for all additional arguments required by the state transition function.

Example: `@constacc`

Data Types: `function_handle`

The Jacobian of the state transition function, specified as a function handle. This function has the same input arguments as the state transition function.

• If `HasAdditiveProcessNoise` is `true`, specify the Jacobian function using one of these syntaxes:

```Jx(k) = statejacobianfcn(x(k)) ```
`Jx(k) = statejacobianfcn(x(k),parameters)`
where `x(k)` is the state at time `k`. The `parameters` argument stands for all additional arguments required by the state transition function.

`Jx(k)` denotes the Jacobian of the predicted state with respect to the previous state. The Jacobian is an M-by-M matrix at time `k`. The Jacobian function can take additional input parameters, such as control inputs or time step size.

• If `HasAdditiveProcessNoise` is `false`, specify the Jacobian function using one of these syntaxes:

```[Jx(k),Jw(k)] = statejacobianfcn(x(k),w(k)) ```
`[Jx(k),Jw(k)] = statejacobianfcn(x(k),w(k),parameters)`
where `x(k)` is the state at time `k` and `w(k)` is a sample Q-element vector of the process noise at time `k`. Q is the size of the process noise covariance. Unlike the case of additive process noise, the process noise vector in the non-additive noise case need not have the same dimensions as the state vector.

`Jx(k)` denotes the Jacobian of the predicted state with respect to the previous state. This Jacobian is an M-by-M matrix at time k. The Jacobian function can take additional input parameters, such as control inputs or time step size.

`Jw(k)` denotes the M-by-Q Jacobian of the predicted state with respect to the process noise elements.

If not specified, the Jacobians are computed by numerical differencing at each call of the `predict` method. This computation can increase the processing time and numerical inaccuracy.

Example: `@constaccjac`

Data Types: `function_handle`

Process noise covariance:

• When `HasAdditiveProcessNoise` is `true`, specify the process noise covariance as a scalar or a positive definite real-valued M-by-M matrix. M is the dimension of the state vector. When specified as a scalar, the matrix is a multiple of the M-by-M identity matrix.

• When `HasAdditiveProcessNoise` is `false`, specify the process noise covariance as an Q-by-Q matrix. Q is the size of the process noise vector.

You must specify `ProcessNoise` before any call to the `predict` method. In later calls to `predict`, you can optionally specify the process noise as a scalar. In this case, the process noise matrix is a multiple of the Q-by-Q identity matrix.

Example: `[1.0 0.05; 0.05 2`]

Option to model processes noise as additive, specified as `true` or `false`. When this property is `true`, process noise is added to the state vector. Otherwise, noise is incorporated into the state transition function.

Measurement model function, specified as a function handle. This function can be a nonlinear function that models measurements from the predicted state. Input to the function is the M-element state vector. The output is the N-element measurement vector. The function can take additional input arguments, such as sensor position and orientation.

• If `HasAdditiveMeasurementNoise` is `true`, specify the function using one of these syntaxes:

```z(k) = measurementfcn(x(k)) ```
`z(k) = measurementfcn(x(k),parameters)`
where `x(k)` is the state at time `k` and `z(k)` is the predicted measurement at time `k`. The `parameters` term stands for all additional arguments required by the measurement function.

• If `HasAdditiveMeasurementNoise` is `false`, specify the function using one of these syntaxes:

```z(k) = measurementfcn(x(k),v(k)) ```
`z(k) = measurementfcn(x(k),v(k),parameters)`
where `x(k)` is the state at time `k` and `v(k)` is the measurement noise at time `k`. The `parameters` argument stands for all additional arguments required by the measurement function.

Example: `@cameas`

Data Types: `function_handle`

Jacobian of the measurement function, specified as a function handle. The function has the same input arguments as the measurement function. The function can take additional input parameters, such sensor position and orientation.

• If `HasAdditiveMeasurmentNoise` is `true`, specify the Jacobian function using one of these syntaxes:

```Jmx(k) = measjacobianfcn(x(k)) ```
`Jmx(k) = measjacobianfcn(x(k),parameters)`
where `x(k)` is the state at time `k`. `Jx(k)` denotes the N-by-M Jacobian of the measurement function with respect to the state. The `parameters` argument stands for all arguments required by the measurement function.

• If `HasAdditiveMeasurmentNoise` is `false`, specify the Jacobian function using one of these syntaxes:

```[Jmx(k),Jmv(k)] = measjacobianfcn(x(k),v(k)) ```
`[Jmx(k),Jmv(k)] = measjacobianfcn(x(k),v(k),parameters)`
where `x(k)` is the state at time `k` and `v(k)` is an R-dimensional sample noise vector. `Jmx(k)` denotes the N-by-M Jacobian of the measurement function with respect to the state. `Jmv(k)` denotes the Jacobian of the N-by-R measurement function with respect to the measurement noise. The `parameters` argument stands for all arguments required by the measurement function.

If not specified, measurement Jacobians are computed using numerical differencing at each call to the `correct` method. This computation can increase processing time and numerical inaccuracy.

Example: `@cameasjac`

Data Types: `function_handle`

Measurement noise covariance, specified as a positive scalar or positive-definite real-valued matrix.

• When `HasAdditiveMeasurementNoise` is `true`, specify the measurement noise covariance as a scalar or an N-by-N matrix. N is the size of the measurement vector. When specified as a scalar, the matrix is a multiple of the N-by-N identity matrix.

• When `HasAdditiveMeasurementNoise` is `false`, specify the measurement noise covariance as an R-by-R matrix. R is the size of the measurement noise vector.

You must specify `MeasurementNoise` before any call to the `correct` method. After the first call to `correct`, you can optionally specify the measurement noise as a scalar. In this case, the measurement noise matrix is a multiple of the R-by-R identity matrix.

Example: `0.2`

Option to enable additive measurement noise, specified as `true` or `false`. When this property is `true`, noise is added to the measurement. Otherwise, noise is incorporated into the measurement function.

## Methods

 clone Create extended Kalman filter object with identical property values correct Correct Kalman state vector and state error covariance matrix correctjpda Correct state and state estimation error covariance using JPDA distance Distance from measurements to predicted measurement initialize Initialize extended Kalman filter likelihood Measurement likelihood predict Predict extended Kalman state vector and state error covariance matrix residual Measurement residual and residual covariance

## Examples

collapse all

Create a two-dimensional `trackingEKF` object and use name-value pairs to define the `StateTransitionJacobianFcn` and `MeasurementJacobianFcn` properties. Use the predefined constant-velocity motion and measurement models and their Jacobians.

```EKF = trackingEKF(@constvel,@cvmeas,[0;0;0;0], ... 'StateTransitionJacobianFcn',@constveljac, ... 'MeasurementJacobianFcn',@cvmeasjac);```

Run the filter. Use the `predict` and `correct` methods to propagate the state. You may call `predict` and `correct` in any order and as many times you want. Specify the measurement in Cartesian coordinates.

```measurement = [1;1;0]; [xpred, Ppred] = predict(EKF); [xcorr, Pcorr] = correct(EKF,measurement); [xpred, Ppred] = predict(EKF); [xpred, Ppred] = predict(EKF)```
```xpred = 4×1 1.2500 0.2500 1.2500 0.2500 ```
```Ppred = 4×4 11.7500 4.7500 0 0 4.7500 3.7500 0 0 0 0 11.7500 4.7500 0 0 4.7500 3.7500 ```

expand all

## Algorithms

The extended Kalman filter estimates the state of a process governed by this nonlinear stochastic equation:

`${x}_{k+1}=f\left({x}_{k},{u}_{k},{w}_{k},t\right)$`

xk is the state at step k. f() is the state transition function. Random noise perturbations, wk, can affect the object motion. The filter also supports a simplified form,

`${x}_{k+1}=f\left({x}_{k},{u}_{k},t\right)+{w}_{k}$`

To use the simplified form, set `HasAdditiveProcessNoise` to `true`.

In the extended Kalman filter, the measurements are also general functions of the state:

`${z}_{k}=h\left({x}_{k},{v}_{k},t\right)$`

h(xk,vk,t) is the measurement function that determines the measurements as functions of the state. Typical measurements are position and velocity or some function of position and velocity. The measurements can also include noise, represented by vk. Again, the filter offers a simpler formulation.

`${z}_{k}=h\left({x}_{k},t\right)+{v}_{k}$`

To use the simplified form, set `HasAdditiveMeasurmentNoise` to `true`.

These equations represent the actual motion and the actual measurements of the object. However, the noise contribution at each step is unknown and cannot be modeled deterministically. Only the statistical properties of the noise are known.

## References

[1] Brown, R.G. and P.Y.C. Wang. Introduction to Random Signal Analysis and Applied Kalman Filtering. 3rd Edition. New York: John Wiley & Sons, 1997.

[2] Kalman, R. E. “A New Approach to Linear Filtering and Prediction Problems.” Transactions of the ASME–Journal of Basic Engineering, Vol. 82, Series D, March 1960, pp. 35–45.

[3] Blackman, Samuel and R. Popoli. Design and Analysis of Modern Tracking Systems, Artech House.1999.

[4] Blackman, Samuel. Multiple-Target Tracking with Radar Applications, Artech House. 1986.

Get trial now