Kalman Computational Procedure Discrete time

Hi Guys,
I'm a beginner in Matlab and still don't know many syntax. I wanted to know if it's possible to do a for loop with two formula?
let's say I have
P0=[10 15;15 20]; %which is the initial Pk
O=[1 1;0 1];
H=[1 1;2 1];
R=[10 15;15 20];
and I need to solve and loop the formulas of:
Pk(-)=O*Pk*O.'+O
Kk=Pk*H.'*inv(H*Pk*H.'+R)
Pk(+)=(1-Kk*H)*Pk
I'm not sure how to loop these formula since I also have to put my initial value Pk=P0 (which was given) or is there a different syntax I need to know?
Thank you so much for your help

 Accepted Answer

Its very easy for 1D cases, as your variables are 2D, How you decide, which is provious data, Say example
P0 =
10 15
25 20
Let say, to calculate the 20 (4th one) data, which element is considered as previous, 15 or 25 or 10?
Here the hints for 1D case, hope you can modify it for 2D array
P0=[10 15];
O=[1 1];
H=[1 1];
R=[10 15];
Pk_minus=zeros(1,length(P0));
for i=2:length(P0)
Pk_minus(i)=O(i-1)*Pk(i-1)*O'+O(i-1)
Kk(i)=......
Pk_plus(i)=........
end

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!