MATLAB implementation of the QUEST algorithm for estimating the state quaternion based on accelerometer and magnetometer data which will then be fed into the orientation kalman filter. It works as far as I can tell, provided you don't approach the singularity as I haven't written the code to detect and handle such a situation. The purpose of the MATLAB implementation was just to check I understood the algorithm correctly and for verifying the C algorithm once it is written and so this extra complexity wasn't necessary.