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' 6 % t_start:start time of solving Riccati equation
10 % outputs: The amount of timesteps to be taken to solve
15 % A: linear system matrix
17 % C: observation matrix
19 % R: sensor noise covariance matrix
21 % Q: process noise covariance matrix
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
28 dt = (t_final - t_start)/outputs;
29 covariances = cell(outputs,1);
30 current_time = t_start;
34 while current_time < t_final
35 covariances{counter,1} = P;
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));
42 P = (1/6).*(k1 + 2.*k2 + 2.*k3 + k4) + P;
45 current_time = current_time + dt; 46 counter = counter + 1; 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)