Created Donnerstag 05 Januar 2017

→→ Documentation

→→ Code

--------------------

## Linear System

The Kalman filter is used to estimate the system states and the output states of a noisy linear system. which can be described as the following:

where:

is the process noise (Gaussian with covariance )

is the measurement noise (Gaussian with covariance )

is the system matrix

is the input matrix

is the output matrix

is the state vector

is the output vector

is the input vector

The noise covariance matrices must follow these conditions:

--------------------

## Nonlinear System

For a nonlinear system, the extended Kalman filter is used to estimate the system states and the output states. A nonlinear system can be described as the following:

where:

is the dynamic model of the system

is the measurement model of the system

is the process noise (Gaussian with covariance )

is the measurement noise (Gaussian with covariance )

is the state vector

is the output vector

is the input vector

The noise covariance matrices also must follow the conditions:

--------------------

## Coding the (Extended) Kalman Filter

### Scenario 1

In principal, there are 2 scenarios of using the Kalman filter. The first scenario is by first simulating the system as shown in the figure below. In this scenario, we only need to supply to the Kalman filter function. The Kalman filter will give us 4 outputs: , , , and .

and are called **the true system states** and **the true system outputs**, respectvely. They are noisy.

and are called **the estimated system states** and **the estimated system outputs**, respectively. They are filtered.

The function prototype for this scenario can be written as:

*[x, z, x_est, z_est] = function kalmanf(u)*

### Scenario 2

The second scenario is used when the measurements are availble. Thus, simulating the system becomes unnecessary. In this scenario, we need to supply and to the kalman filter function. The Kalman filter will give us 2 outputs: (the estimated system sates) and (the estimated system outputs).

The function prototype for this scenario can be written as:

*[x_est, z_est] = function kalmanf(z_meas, u)*