Revision 7, 0.8 kB
(checked in by smidl, 16 years ago)
|
nefunkcni!!!
|
Rev | Line | |
---|
[7] | 1 | #include <itpp/itbase.h> |
---|
| 2 | #include "libKF.h" |
---|
| 3 | #include "libDC.h" |
---|
| 4 | |
---|
| 5 | using namespace itpp; |
---|
| 6 | |
---|
| 7 | //These lines are needed for use of cout and endl |
---|
| 8 | using std::cout; |
---|
| 9 | using std::endl; |
---|
| 10 | |
---|
| 11 | int main() { |
---|
| 12 | |
---|
| 13 | mat A="1 -0.5; 1 0"; |
---|
| 14 | mat B="1;0"; |
---|
| 15 | mat C="1 0"; |
---|
| 16 | mat D="0"; |
---|
| 17 | ldmat R=ldmat("0.1"); |
---|
| 18 | ldmat Q=ldmat("0.2 0 ; 0 0.02"); |
---|
| 19 | |
---|
| 20 | ldmat P0=Q; P0*=1000.0; //increase P0 |
---|
| 21 | vec mu0="0 0"; |
---|
| 22 | |
---|
| 23 | Kalman<ldmat> KF( A,B,C,D,R,Q,P0,mu0 ); |
---|
| 24 | // cout << KF; |
---|
| 25 | |
---|
| 26 | it_file fin( "matlab/testKF.it" ); |
---|
| 27 | mat Dt; |
---|
| 28 | |
---|
| 29 | fin >> Name( "d" ) >> Dt; |
---|
| 30 | int Ndat = Dt.cols(); |
---|
| 31 | mat Xt=zeros( 2,Ndat ); |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | Xt.set_col( 0,KF.mu ); |
---|
| 35 | for ( int t=1;t<Ndat;t++ ) { |
---|
| 36 | KF.bayes( Dt.get_col( t )); |
---|
| 37 | Xt.set_col(t,KF.mu); |
---|
| 38 | // Kmu = KF.mu; |
---|
| 39 | // cout << "t:" <<t<< " " << dt<<" "<<Kmu <<endl; |
---|
| 40 | |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | it_file fou( "matlab/testKF_res.it" ); |
---|
| 44 | fou << Name("xth") << Xt; |
---|
| 45 | //Exit program: |
---|
| 46 | return 0; |
---|
| 47 | |
---|
| 48 | } |
---|