I 've done some modification base on the latest matlab code which plot the curve of estimation of z against the real measured z
Main Kalman filtering running
% Kalman Filter Inovation Processing
% data is a row vector with the independent vars and the depended var
H=Data(1:ll-1); %extract the H matrix or vector from the data
z=Data(ll); %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
You may randomly input some data matrix to test.
% function to run simulation of the Kalman filter for
% MHF question
% data is a matrix each row of which contains the vector of data
% The system model is:
% z=sum(x(i)*aa(i)) + w
% where z is the measurement to be explained, the x's are the
% independent variables corresponding to z and w is a scalar zero
% mean gaussian noise term.
% Initial values, the state estimate is set to zero, and the covariance
% to a diagonal matrix of the right dimension with 10^2 down the diagonal
% the measurement noise variance R (of w in the model) is set to 1.
niter=sz(1); %number of rows of data
ll=sz(2); %length of each row of data
P=eye(ll-1,ll-1).*1000000; %initial covariance of state estimate
X=zeros(ll-1,1); %initial state estimate
R=0.2; %measurement variance
D=data(idx,:); % load the nest line of data into D consists of [x(1),..,x(n),z]
[X,P]=KalmanInov(D,R,X,P); % inovate the filter with the data vactor D
rv=[rv,X];%accumulate the state estimate
The picture attached is the result.
Can i do that in this way?