You combine your step count with the feel of the wall to figure out your exact location.
% Run the Kalman filter x = zeros(2, length(t)); P = zeros(2, 2, length(t)); x(:, 1) = x0; P(:, :, 1) = P0; for i = 2:length(t) % Prediction step x_pred = A * x(:, i-1); P_pred = A * P(:, :, i-1) * A' + Q;
Enter the —a mathematical superpower that blends predictions (where you think you are) with measurements (what sensors see) to produce an optimal estimate of the truth. Invented by Rudolf E. Kálmán in 1960, it is the engine behind Apollo’s moon landing, drone stabilization, missile guidance, stock market prediction (simplified), and even your smartphone’s GPS.
for k = 1:length(t) % --- Predict --- x_pred = A * x_est; P_pred = A * P_est * A' + Q;
% Measurement Noise (Uncertainty of the sensor) R = 25;
% Update K = P_p*H'/(H*P_p*H' + R); xhat = xhat_p + K*(z - H*xhat_p); P = (eye(2) - K*H)*P_p;