• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Integral Systems Corp.

  • Home
  • General
  • Guides
  • Reviews
  • News

Examples Download Top | Kalman Filter For Beginners With Matlab

Goal: estimate x_k given measurements z_1..z_k. Predict: x̂_k-1 = A x̂_k-1 + B u_k-1 P_k-1 = A P_k-1 A^T + Q

% 1D constant velocity Kalman filter example dt = 0.1; A = [1 dt; 0 1]; H = [1 0]; Q = [1e-4 0; 0 1e-4]; % process noise covariance R = 0.01; % measurement noise variance x = [0; 1]; % true initial state xhat = [0; 0]; % initial estimate P = eye(2); Goal: estimate x_k given measurements z_1

T = 100; pos_true = zeros(1,T); pos_meas = zeros(1,T); pos_est = zeros(1,T); A = [1 dt

MATLAB code:

Update: K_k = P_k-1 H^T (H P_k-1 H^T + R)^-1 x̂_k = x̂_k + K_k (z_k - H x̂_k) P_k = (I - K_k H) P_k-1 H = [1 0]

for k = 1:T w = mvnrnd(zeros(4,1), Q)'; v = mvnrnd(zeros(2,1), R)'; x = A*x + w; z = H*x + v; % Predict xhat_p = A*xhat; P_p = A*P*A' + Q; % Update K = P_p*H'/(H*P_p*H' + R); xhat = xhat_p + K*(z - H*xhat_p); P = (eye(4) - K*H)*P_p; true_traj(:,k) = x; meas(:,k) = z; est(:,k) = xhat; end

Footer

Contact Info

Email: Phone:

Address Info

P.O. Box 1570
810 Downingtown Pike
West Chester, PA 19380

Site Links

  • Services
    • Application Engineering
    • End User Support
    • Systems Engineering
    • Internet Presence
    • Network Engineering
    • Specialty Services
  • Tech Tips
  • Contact Us

Copyright © 2025 · Integral Systems Corp

%!s(int=2026) © %!d(string=Pure Curious Lumen)