-
Notifications
You must be signed in to change notification settings - Fork 3
/
Update2.m
executable file
·51 lines (27 loc) · 1.18 KB
/
Update2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [xkk,Skk] = Update2(xkk1,Skk1,z)
global Rsqrt;
%%%========================================================================
%%% Althought algebraically equivalent to Update.m, Update2 is
%%% mathematically more elegant (Read `Hybrid CKF')
%%%========================================================================
%%%========================================================================
%%% Genrate a set of Cubature Points
%%%========================================================================
nx = 2; %state vector dimension
nz = 2; %mst vector dimension
nPts = 2*nx;
CPtArray = sqrt(nPts/2)*[eye(nx) -eye(nx)];
%%%========================================================================
Xi = repmat(xkk1,1,nPts) + Skk1*CPtArray;
Zi = MstEq(Xi);
zkk1 = sum(Zi,2)/nPts; % predicted Measurement
X = (Xi-repmat(xkk1,1,nPts))/sqrt(nPts);
Z = (Zi-repmat(zkk1,1,nPts))/sqrt(nPts);
[foo,S] = qr([Z Rsqrt; X zeros(nx,nz)]',0);
S = S';
A = S(1:nz,1:nz); % Square-root Innovations Covariance
B = S(nz+1:end,1:nz);
C = S(nz+1:end,nz+1:end);
G = B/A; % Cubature Kalman Gain
xkk = xkk1 + G*(z-zkk1);
Skk = C;