File: srkf.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (34 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [x1,p1]=srkf(y,x0,p0,f,h,q,r)
//square root kalman filter algorithm
//Input to the macro is:
// f,h    :current system matrices
// q,r    :covariance matrices of dynamics
//        :and observation noise
// x0,p0  :state estimate and error variance
//        :at t=0 based on data up to t=-1
// y      :current observation
//
//Output from the macro is:
// x1,p1  :updated estimate and error covariance
//        :at t=1 based on data up to t=0
//!
// author: C. Bunks  date: 9 August 1988
// Copyright INRIA

   n=maxi(size(x0));
   p=maxi(size(y));
 
   j=[chol(r)',0*r];
   g=[0*q,chol(q)'];
 
   mat=[h*p0,j;f*p0,g];
   [q,tmat]=qr(mat')';
   p1=tmat(p+1:p+n,p+1:p+n);
   k=tmat(p+1:p+n,1:p);
   re=tmat(1:p,1:p);
 
   epsilon=y-h*x0;
   x1=f*x0+k*(re**(-1))*epsilon;