% Plot results t = 1:num_steps; plot(t, measurements, 'r.', 'MarkerSize', 8); hold on; plot(t, x_hat_log(1,:), 'b-', 'LineWidth', 1.5); xlabel('Time step'); ylabel('Position'); legend('Noisy measurements', 'Kalman filter estimate'); title('1D Position Tracking with Kalman Filter'); grid on;
% Noise covariances Q = [0.01 0; 0 0.01]; % process noise (small) R = 1; % measurement noise (variance) kalman filter for beginners with matlab examples pdf
x_hat_log(:,k) = x_hat; end