Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. function y = kalmanFilter(gyro,accel,R, Q, C, B, A)
  2.  
  3. % Initial conditions
  4. persistent x_est p_est
  5. if isempty(x_est)
  6. x_est = zeros(2, 1);
  7. p_est = eye(2);
  8. end
  9. % Predykcja
  10. x_prd = A*(x_est)' + B + gyro;
  11. p_prd = A*p_est*A' + Q;
  12.  
  13. % Estymacja
  14. K = p_est*C'/(C*p_est*C' + R);
  15. x_est = x_prd - K*C*x_prd + K*accel;
  16. p_est = p_prd - K*C*p_prd;
  17.  
  18. % Wynik
  19. y=C*x_est;
  20.  
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement