Attitude extended Kalman filter (EKF) with quaternions
Version 1.2 (3.36 MB) by
Paolo Massioni
An implementation of the EKF with quaternions. Simulation and Arduino Simulink code for MKR1000 or MKR1010 with IMU Shield
An implementation of the EKF with quaternions and angular rate bias, coded inside a Matlab function in Simulink.
Two Simulink files are provided: a simulation with real IMU data and and Arduino Simulink code for MKR1000 with IMU Shield. You do not need an Arduino if you wish to run only the simulation.
The code is loosely based on what explained here https://thepoorengineer.com/en/ekf-impl/ (not written by me), a pdf with an explanation of the algorithm is provided (excerpt from my lecture notes in aircraft dynamics).
Try and see which values of the matrices R and Q give the best results.
Enjoy.
Cite As
Paolo Massioni (2026). Attitude extended Kalman filter (EKF) with quaternions (https://www.mathworks.com/matlabcentral/fileexchange/119583-attitude-extended-kalman-filter-ekf-with-quaternions), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2022b
Compatible with R2022b
Platform Compatibility
Windows macOS LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
