KalmanFilter
ddekf_update_phase.m
Go to the documentation of this file.
1 function [estimate_next, covariance_sqrt] = ddekf_update_phase(R_root,P_root,C,estimate,measurement)
2 %runs update portion of the dd-ekf.
3 %[estimate_next,covariance_sqrt] = ddekf_update_phase(R_root,P_root,C,estimate,measurement)
4 %INPUT:
5 % R_root:sensor error covariance matrix where
6 % R=R_root*(R_root')
7 %
8 % P_root:covariance matrix from the predict phase
9 % P_predict = P_root*(root')
10 %
11 % C: observation matrix
12 %
13 % estimate: estimate from predict phase
14 %
15 % measurement: measurement picked up by sensor
16 %
17 %OUTPUT:
18 % estimate_next: estimate incorporating measurement
19 %
20 % covariance_sqrt: square root of covariance at the
21 % end of update phase. Actual covariance is
22 % covariance_sqrt*(covariance_sqrt')
23 
24  measurement_count = size(C,1);
25  state_count = size(C,2);
26 
27  tmp = zeros(state_count+measurement_count, state_count+measurement_count);
28  tmp(1:measurement_count,1:measurement_count) = R_root;
29  tmp(1:measurement_count,(measurement_count+1):end) = C*P_root;
30  tmp((1+measurement_count):end,(1+measurement_count):end) = P_root;
31 
32  [Q,R] = qr(tmp');
33  R = R';
34 
35  X = R(1:measurement_count,1:measurement_count);
36  Y = R((1+measurement_count):end,(1:measurement_count));
37  Z = R((1+measurement_count):end,(1+measurement_count):end);
38 
39  %Kalman_gain = Y*inv(X);
40  estimate_next = estimate + Y*(X\(measurement - C*estimate));
41  covariance_sqrt = Z;
42 end
function ddekf_update_phase(in R_root, in P_root, in C, in estimate, in measurement)