Originally Posted by

**atlove** CaptainBlack

do you have some example about the application of kalman filtering which somehow similar to my project?

i have read many material , i want some example to further my understanding.

if you don't have , just leave it, doesn't matter,

thank you very much

I have implemented a 2-D verion of your problem in Matlab, the code follows:

Code:

function rv=DataGen
x=rand(1,2).*20;
y=sum(x)+randn(1,1);
rv=[x,y];

This generates a data set such that the third element is the sum of the first two plus a normally distributed random number of unit variance.

(the model is $\displaystyle d_3=d_1+d_2+w$, I use d here as x is usually reserved for the state )

Code:

function [X,P]=KalmanInov(Data,R,X,P)
%
% Kalman Filter Inovation Processing
%
%
%
H=[Data(1),Data(2)]; %extract the H matrix or vector from the data
z=Data(3); %extract the measurement from the data
% Below is the standard Kalman inovation equations in matrix form
S=H*P*H'+R; %note this is a scalar
K=P*H'*inv(S);
X=X+K*(z-H*X);
P=(diag([1,1])-K*H)*P;

The above is the Kalman innovation process straight from the book X on input is the old state estimate, and on exit the new state estimate, and P on input is the prior state covariance matrix and on exit is the posterior state estimate.

Code:

function rv=KalmanSim
P=[100,0;0,100]; %initial covariance of state estimate
X=[0;0]; %initial state estimate
R=1; %measurement variance
rv=X
for idx=1:10
D=DataGen; % generate some data
[X,P]=KalmanInov(D,R,X,P);
rv=[rv,X]; %accumulate the state estimate
end

The above loops over 10 sets of data, plotting the rows of the returned matrix will show the evolution of the state estimate, which tend to [1,1]'

Note there is no need for a dynamic with this model.

The attached figure shows the evolution of the components of the state estimate.

CB