Projet

Général

Profil

« Précédent | Suivant » 

Révision 564

Ajouté par Guillaume DAVID il y a environ 3 ans

ajout formules prediction et gain

Voir les différences:

branch/david_guillaume/sp4a3/sp4a3_kalman.c
debug=0; ///Mettre à 1 pour afficher les matrices.
///Ajouter votre code ci-dessous///
// Kalman
// Kalman
/**< PREDICTION >**/
/** X = F*X **/
double X1[4][1];
Mul_Mat_Mat(4,4,F,4,1,X,X1);
/** P = F*P*Ft + Q **/
double Pint1[4][4],Pint2[4][4],P1[4][4];
Mul_Mat_Mat(4,4,P,4,4,FT,Pint1);
Mul_Mat_Mat(4,4,F,4,4,Pint1,Pint2);
Add_Mat_Mat(4,4,Pint1,4,4,Q,P1);
/**< GAIN >**/
/** K = P1*Ht*inv(H*P1*Ht + R) **/
double Kint1[4][4],Kint2[4][4],Kint3[4][4],Kint4[4][4],Kint5[4][4];
Mul_Mat_Mat(4,4,P1,4,2,HT,Kint1);
Mul_Mat_Mat(2,4,H,4,2,Kint1,Kint2);
Add_Mat_Mat(2,2,Kint2,2,2,R,Kint3);
Inverse_Mat_22(2,2,Kint3,Kint4);
Mul_Mat_Mat(4,2,HT,2,2,Kint4,Kint5);
Mul_Mat_Mat(4,4,P1,4,2,Kint5,K);
/**< MISE A JOUR >**/
/** X11 = X1+ K*D **/
// X = F*X
Plot_Mat(X," X(k+1|k) = ");
Plot_Mat(X1," X(k+1|k) = ");
//P = F*P*F'+Q;
Plot_Mat(P,"P(k+1|k) = F.P(k|k).FT + Q = ");
Plot_Mat(P1,"P(k+1|k) = F.P(k|k).FT + Q = ");
// K = P*H' / ( H*P*H' + R);
Plot_Mat(K,"K = ");
//X = X + K*([xobs(i);yobs(i)]-H*X);
//Plot_Mat(Delta,"DELTA = Obs - H.X(k+1|k)");
Plot_Mat(X," X(k+1|k+1) = X(k+1|k) + K.Delta = ");
Plot_Mat(X11," X(k+1|k+1) = X(k+1|k) + K.Delta = ");
// P = P - K*H*P;
Plot_Mat(P," P(k+1|k+1) = P(k+1|k) - K.H.P(k+1|k) = ");
Plot_Mat(P11," P(k+1|k+1) = P(k+1|k) - K.H.P(k+1|k) = ");
/// La matrice X doit contenir la position filtrée ///
}

Formats disponibles : Unified diff