Guest User

Untitled

a guest
May 25th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. function [xk, Pk] = KalmanTrack(x, P)
  2.  
  3. %Model
  4. Phi = eye(4); Phi(1,3) = 1; Phi(2,4) = 1;
  5. H =eye(2,4);
  6. %Noise
  7. Q = eye(4);
  8. R = eye(2);
  9. %% Prediction
  10. %State prediction
  11. xk = Phi*x;
  12.  
  13. %Observation model
  14. zk = H*x;
  15.  
  16. %Error covariance for the predicted estimate
  17. Pk = Phi*P*Phi'+Q;
  18. %% Update
  19. %optimal Kalman gain
  20. K = Pk*H'*inv(H*Pk*H'+R)
  21.  
  22. %Residual
  23. xk = Phi*x+K*(zk - H*Phi*x);
  24. disp(K*(zk - H*Phi*x));
  25.  
  26. %Updating the error covariance
  27. Pk = (eye(4) - K*H)*Pk;
Add Comment
Please, Sign In to add comment