Neither source is perfectly accurate. The Kalman filter acts as the ultimate mathematical judge. It looks at the uncertainty of your prediction and the uncertainty of your measurement, calculates the optimal middle ground, and gives you the absolute best estimate of your true position. Why is it so popular?
MATLAB code:
1. MATLAB Central File Exchange (Official Community Downloads) Neither source is perfectly accurate
+---------------------------------------+ | | | START | | Initial Estimate | | | +-------------------+-------------------+ | v +-------------------+-------------------+ | | | 1. PREDICT | | Project the state ahead using | | physics equations | | | +-------------------+-------------------+ | | (Time Update) v +-------------------+-------------------+ | | | 2. UPDATE | | Correct the prediction using | | new sensor measurements | | | +-------------------+-------------------+ | +-------------------+ 1. The Predict Step (Time Update)
If you found this article helpful, share it with a fellow engineer. The code is free, the knowledge is powerful, and the filter is forever. Why is it so popular
The Kalman filter is a recursive algorithm that uses a combination of prediction and measurement updates to estimate the state of a system. It takes into account the uncertainty of the measurements and the system dynamics to produce an optimal estimate of the state.
% Position Plot subplot(2, 1, 1); plot(t, true_position, 'g', 'LineWidth', 2); hold on; plot(t, measured_position, 'r.'); plot(t, est_position, 'b-', 'LineWidth', 2); legend('True Position', 'Noisy Measurement', 'Kalman Estimate'); xlabel('Time (s)'); ylabel('Position (m)'); title('Kalman Filter Tracking a Falling Object'); grid on; PREDICT | | Project the state ahead using
The Kalman filter algorithm can be summarized as follows: