One way to create an extended Kalman filter without using Matlab's built-in extendedKalmanFilter
function is by implementing the prediction and correction steps manually.
Firstly, define your system model and measurement model, which can be represented by state transition function f
and observation function h
. The state transition and observation model are:
main.m55 chars3 lines
where x_k
is the state at time step k
, u_k
is the control input, z_k
is the measurement at time step k
, w_k
and v_k
are process and measurement noise respectively.
Next, initialize the initial state estimate x_0
, the initial state covariance matrix P_0, and the process noise and measurement noise covariance matrices Q
and R
.
Then, for each time step, perform the following steps:
k
:main.m82 chars3 lines
where F_k-1
is the Jacobian matrix of f
at x_k-1
and u_k-1
.
k
:main.m145 chars4 lines
where H_k
is the Jacobian matrix of h
at x_k_pred
.
Repeat these steps for each time step.
Note that matrix multiplication is used extensively in both prediction and correction steps.
Here's an example implementation in Matlab:
main.m1167 chars30 lines
gistlibby LogSnag