KalmanFilter
cckf.m
Go to the documentation of this file.
1 function [covariances] = cckf(t_start,t_final,outputs,P_0,A,C,R,Q)
2 %Solves Differential Riccati equation by using very simple
3 %Euler scheme. Hence this implementation should not be used
4 %for higher mode count or anything 'serious'
5 %INPUT:
6 % t_start:start time of solving Riccati equation
7 %
8 % t_final: finish time
9 %
10 % outputs: The amount of timesteps to be taken to solve
11 % P(t)
12 %
13 % P_0: P(t_start)
14 %
15 % A: linear system matrix
16 %
17 % C: observation matrix
18 %
19 % R: sensor noise covariance matrix
20 %
21 % Q: process noise covariance matrix
22 %OUTPUT:
23 % covariances: cell of size outputsX1
24 % where the ith entry of cell array is
25 % covariances{i,1} = P(t_start + (i-1)*dt)
26 % where dt = (t_final-t_start)/outputs
27 
28 dt = (t_final - t_start)/outputs;
29 covariances = cell(outputs,1);
30 current_time = t_start;
31 
32 P = P_0;
33 counter = 1;
34 while current_time < t_final
35  covariances{counter,1} = P;
36 
37  k1 = reshape(dt.*mRiccati(current_time,P,A,C,R,Q),size(A));
38  k2 = reshape(dt.*mRiccati(current_time + dt/2,P + 0.5.*k1,A,C,R,Q),size(A));
39  k3 = reshape(dt.*mRiccati(current_time + dt/2,P + 0.5.*k2,A,C,R,Q),size(A));
40  k4 = reshape(dt.*mRiccati(current_time + dt,P + k3,A,C,R,Q),size(A));
41 
42  P = (1/6).*(k1 + 2.*k2 + 2.*k3 + k4) + P;
43  P = 0.5*(P + P');
44 
45  current_time = current_time + dt;
46  counter = counter + 1;
47 end
48 
49 end
function mRiccati(in t, in X, in A, in C, in R, in Q)
function cckf(in t_start, in t_final, in outputs, in P_0, in A, in C, in R, in Q)