blob: 739e96537e8d61a4e282f6ac6820a39666d7895b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
// Kalman filter example of estimating a constant
// 14.4
function [xhat,P,y] = kal_ex(x,xline,M)
y = x + rand();
Q = 0; R = 1;
xhat_ = xline;
P_ = M + Q;
K = P_/(P_+R);
P = (1-K)*P_;
xhat = xhat_ + K*(y-xhat_);
endfunction;
|