% kalman_gain_update() - update Ke, Kv, and G
%
function kalman_gain_update()

global A;
global AT;
global Ke;
global Ku;
global Kn;
global Ke;
global Kv;
global G;
global GT;

Ke = A*Ke*AT + Ku;		% Ke(l|l-1)

Kv = Ke(1,1) + Kn;		% assuming C=[1 0]

G = Ke(:,1) / Kv;		% Ke * C' * inv(Kv)

GT = G';

Ke = Ke - G * Ke(1,:);		% Ke(l|l) = Ke(l|l-1) - G * C * Ke(l|l-1)
