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)
5 % R_root:sensor error covariance matrix where
8 % P_root:covariance matrix from the predict phase 9 % P_predict = P_root*(root')
11 % C: observation matrix
13 % estimate: estimate from predict phase
15 % measurement: measurement picked up by sensor
18 % estimate_next: estimate incorporating measurement
20 % covariance_sqrt: square root of covariance at the
21 % end of update phase. Actual covariance is
22 % covariance_sqrt*(covariance_sqrt
') 24 measurement_count = size(C,1); 25 state_count = size(C,2); 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; 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); 39 %Kalman_gain = Y*inv(X); 40 estimate_next = estimate + Y*(X\(measurement - C*estimate)); function ddekf_update_phase(in R_root, in P_root, in C, in estimate, in measurement)