KalmanFilter
cubature_predict_phase.m
Go to the documentation of this file.
1 function [estimate, covariance_sqrt] = cubature_predict_phase(f_func,t,P_0_sqrt,x_0,Q_root)
2 %runs predict portion of update of the dd-ekf
3 %[estimate, covariance_sqrt] cubature_predict_phase(f_func,t,P_0_sqrt,x_0,Q_root)
4 %INPUT:
5 % f_func: x_{k+1} = f_func(x_k,t) where x_k is the state. The
6 % function's second argument is time t for cases when the function
7 % changes with time.
8 %
9 % t: current time
10 %
11 % X_0: estimate of x at start_time
12 %
13 % P_0_sqrt: square root factor of covariance P at
14 % start_time. P_0 = P_0_sqrt*(P_0_sqrt')
15 %
16 % Q_root: square root of process noise covariance matrix
17 % Q where Q = Q_root*(Q_root');
18 %
19 %OUTPUT:
20 % estimate: estimate of x after predict phase
21 %
22 % covariance_sqrt: square root of covariance P after predict phase
23 % P = covariance_sqrt*(covariance_sqrt')
24 
25  x = x_0;
26  state_count = length(x);
27 
28  sigma_points = zeros(state_count,state_count*2);
29  sigma_points(:,1:state_count) = x_0 + P_0_sqrt*sqrt(state_count).*eye(state_count,state_count);
30  sigma_points(:,(state_count+1):end) = x_0 - P_0_sqrt*sqrt(state_count).*eye(state_count,state_count);
31 
32  for i=1:(2*state_count)
33  sigma_points(:,i) = f_func(sigma_points(:,i),t);
34  end
35 
36  estimate = (1/(2*state_count))*sum(sigma_points,2);
37 
38  covariance = zeros(state_count,state_count);
39  for i=1:(2*state_count)
40  covariance = covariance + (sigma_points(:,i)-estimate)*(sigma_points(:,i)-estimate)';
41  end
42  covariance = 1/(2*state_count) * covariance + Q_root*Q_root';
43 
44  covariance_sqrt = chol(covariance)';
45 end
function cubature_predict_phase(in f_func, in t, in P_0_sqrt, in x_0, in Q_root)