Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create extended Kalman filter object for online state estimation

`obj = extendedKalmanFilter(StateTransitionFcn,MeasurementFcn,InitialState)`

`obj = extendedKalmanFilter(StateTransitionFcn,MeasurementFcn,InitialState,Name,Value)`

`obj = extendedKalmanFilter(StateTransitionFcn,MeasurementFcn)`

`obj = extendedKalmanFilter(StateTransitionFcn,MeasurementFcn,Name,Value)`

`obj = extendedKalmanFilter(Name,Value)`

creates
an extended Kalman filter object for online state estimation of a
discrete-time nonlinear system. `obj`

= extendedKalmanFilter(`StateTransitionFcn`

,`MeasurementFcn`

,`InitialState`

)`StateTransitionFcn`

is
a function that calculates the state of the system at time *k*,
given the state vector at time *k*-1. `MeasurementFcn`

is
a function that calculates the output measurement of the system at
time *k*, given the state at time *k*. `InitialState`

specifies
the initial value of the state estimates.

After creating the object, use the `correct`

and `predict`

commands to update state estimates
and state estimation error covariance values using a first-order discrete-time
extended Kalman filter algorithm and real-time data.

specifies
additional attributes of the extended Kalman filter object using one
or more `obj`

= extendedKalmanFilter(`StateTransitionFcn`

,`MeasurementFcn`

,`InitialState`

,`Name,Value`

)`Name,Value`

pair arguments.

creates
an extended Kalman filter object using the specified state transition
and measurement functions. Before using the `obj`

= extendedKalmanFilter(`StateTransitionFcn`

,`MeasurementFcn`

)`predict`

and `correct`

commands,
specify the initial state values using dot notation. For example,
for a two-state system with initial state values `[1;0]`

,
specify `obj.State = [1;0]`

.

specifies
additional attributes of the extended Kalman filter object using one
or more `obj`

= extendedKalmanFilter(`StateTransitionFcn`

,`MeasurementFcn`

,`Name,Value`

)`Name,Value`

pair arguments. Before using
the `predict`

and `correct`

commands,
specify the initial state values using `Name,Value`

pair
arguments or dot notation.

creates
an extended Kalman filter object with properties specified using one
or more `obj`

= extendedKalmanFilter(`Name,Value`

)`Name,Value`

pair arguments. Before using
the `predict`

and `correct`

commands,
specify the state transition function, measurement function, and initial
state values using `Name,Value`

pair arguments
or dot notation.

`extendedKalmanFilter`

creates an object
for online state estimation of a discrete-time nonlinear system using
the first-order discrete-time extended Kalman filter algorithm.

Consider a plant with states *x*, input *u*,
output *y*, process noise *w*, and
measurement noise *v*. Assume that you can represent
the plant as a nonlinear system.

The algorithm computes the state estimates $$\widehat{x}$$ of the nonlinear system using state transition and measurement functions specified by you. The software lets you specify the noise in these functions as additive or nonadditive:

**Additive Noise Terms**— The state transition and measurements equations have the following form:$$\begin{array}{l}x[k]=f(x[k-1],{u}_{s}[k-1])+w[k-1]\\ y[k]=h(x[k],{u}_{m}[k])+v[k]\end{array}$$

Here

*f*is a nonlinear state transition function that describes the evolution of states`x`

from one time step to the next. The nonlinear measurement function*h*relates`x`

to the measurements`y`

at time step`k`

.`w`

and`v`

are the zero-mean, uncorrelated process and measurement noises, respectively. These functions can also have additional input arguments that are denoted by`u`

and_{s}`u`

in the equations. For example, the additional arguments could be time step_{m}`k`

or the inputs`u`

to the nonlinear system. There can be multiple such arguments.Note that the noise terms in both equations are additive. That is,

`x(k)`

is linearly related to the process noise`w(k-1)`

, and`y(k)`

is linearly related to the measurement noise`v(k)`

.**Nonadditive Noise Terms**— The software also supports more complex state transition and measurement functions where the state*x*[*k*] and measurement*y*[*k*] are nonlinear functions of the process noise and measurement noise, respectively. When the noise terms are nonadditive, the state transition and measurements equation have the following form:$$\begin{array}{l}x[k]=f(x[k-1],w[k-1],{u}_{s}[k-1])\\ y[k]=h(x[k],v[k],{u}_{m}[k])\end{array}$$

When you perform online state estimation, you first create the
nonlinear state transition function *f* and measurement
function *h*. You then construct the `extendedKalmanFilter`

object
using these nonlinear functions, and specify whether the noise terms
are additive or nonadditive. You can also specify the Jacobians of
the state transition and measurement functions. If you do not specify
them, the software numerically computes the Jacobians.

After you create the object, you use the `predict`

command to predict state estimate
at the next time step, and `correct`

to correct state estimates
using the algorithm and real-time data. For information about the
algorithm, see Extended and Unscented Kalman Filter Algorithms for Online State Estimation.

You can use the following commands with `extendedKalmanFilter`

objects:

Command | Description |
---|---|

`correct` | Correct the state and state estimation error covariance
at time step |

`predict` | Predict the state and state estimation error covariance at time the next time step. |

`clone` | Create another object with the same object property values. Do
not create additional objects using syntax |

For `extendedKalmanFilter`

object properties,
see Properties.