KalmanFilter
update_phase.m
Go to the documentation of this file.
1 function [estimate_next, covariance_sqrt] = update_phase(R_root,P_root,C,estimate,measurement)
2 %runs update portion of the 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 % covariance_sqrt: square root of covariance at the
19 % end of update phase. Actual covariance is
20 % covariance_sqrt*(covariance_sqrt')
21 
22  measurement_count = size(C,1);
23  state_count = size(C,2);
24 
25  tmp = zeros(state_count+measurement_count, state_count+measurement_count);
26  tmp(1:measurement_count,1:measurement_count) = R_root;
27  tmp(1:measurement_count,(measurement_count+1):end) = C*P_root;
28  tmp((1+measurement_count):end,(1+measurement_count):end) = P_root;
29 
30  [Q,R] = qr(tmp');
31  R = R';
32 
33  X = R(1:measurement_count,1:measurement_count);
34  Y = R((1+measurement_count):end,(1:measurement_count));
35  Z = R((1+measurement_count):end,(1+measurement_count):end);
36 
37  %Kalman_gain = Y*inv(X);
38  estimate_next = estimate + Y*(X\(measurement - C*estimate));
39  covariance_sqrt = Z;
40 end
function update_phase(in R_root, in P_root, in C, in estimate, in measurement)
function ddekf_update_phase(in R_root, in P_root, in C, in estimate, in measurement)