Kalman Filter Program

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

p=input('enter the length of the state transition matrix :'); A=input('enter the n coefficients of the poles of the AR(n)

process :'); if length(A)~=p disp('there is an error in the coefficients length entered... please enter o nce more :'); A=input('enter the n coefficients of the poles of the AR(n) process :'); end A=[A;eye(p-1,p)];% this is the pxp state transition matrix. Qw=input('Please enter the white noise variance of W(n) :'); Qv=input('Please enter the white noise variance of V(n) :'); Po=1;% this is the error covariance P(0|0) assumed to be 1 Pnpast=Po;% this is the error covarince vector P(n-1|n-1) %Pnpresent is P(n|n-1) %Pn is P(n|n) N=input('please enter the number of times we want to calculate the K(n) :'); for n=1:N Pnpresent=(A)*(Pnpast)*(A.')+Qw; K=Pnpresent/(Pnpresent+Qv); Pn=(1-K)*Pnpresent; Pnpast=Pn; end disp('the value of K(n) after N iteration is '); disp(K);

You might also like