KalmanFilter
test_cdekf_predict.m
Go to the documentation of this file.
1 addpath('../continuous_discrete');
2 
3 P_cell = {[5,0.5;0.5,3], [1 2 6;2 9 0.5; 6,0.5,0.1]};
4 for i=1:length(P_cell)
5  P = P_cell{1,i}:
6  state_count = size(P,1);
7  r = 0.001;
8  P_0_sqrt = chol(P)';
9  X_0 = randn(state_count,1);
10  Q_root = 1*eye(state_count);
11  Q = Q_root*Q_root;
12  assert(max(max(abs(P_0_sqrt*P_0_sqrt'-P)))<0.000000001);
13 
14  A = randn(state_count,state_count);
15  f_func = @(x,t) A*x + 0*t;
16  jacobian_func = @(x,t) A + 0.*x + 0*t;
17 
18  h = 0.0001;
19  del_t = 2;
20  start_time = 0;
21 
22  [estimate, covariance_sqrt] = cdekf_predict_phase(f_func,jacobian_func,h,del_t,start_time,P_0_sqrt,X_0,Q_root);
23 
24  cur_time = 0;
25  p = P;
26  x = X_0;
27  phi = eye(state_count);
28  phi_sum = zeros(state_count);
29  while(cur_time < del_t)
30  phi_next = phi + (h).*(jacobian_func(x,cur_time)*phi);
31  phi_sum = phi_sum + (h/2).*( phi*Q*phi' + phi_next*Q*phi_next');
32 
33  x = x + h*f_func(x,cur_time);
34  p = p + h.*( jacobian_func(x,cur_time)*p + p*jacobian_func(x,cur_time)' + Q_root*Q_root);
35  cur_time = cur_time + h;
36 
37  phi = phi_next;
38  end
39  phi_sum = phi_sum + phi*P*phi';
40 
41  assert(max(max(abs(covariance_sqrt*(covariance_sqrt')-p)))<0.000000001);
42 
43 end
function cdekf_predict_phase(in f_func, in jacobian_func, in h, in dt_between_measurements, in start_time, in P_0_sqrt, in x_0, in Q_root)