How to calculate attitude from IMU ?
For example, mathematical equations
Robotics Stack Exchange is a question and answer site for professional robotic engineers, hobbyists, researchers and students. It only takes a minute to sign up.
Sign up to join this communityAltitude is usually determined from pressure and temperature sensors of an IMU. You can see a formula here.
However, you must realize that raw data from a sensor is NEVER RELIABLE. Sensors do not always give a correct reading. Instead, they give you a value somewhat close to the true value, but with some random "noise" added to it. So, instead of just using the data that you obtain from the sensor, you should always filter out the noise using some form of kalman filter.
An aircraft's attitude can be calculated from an IMU, but a full-fledged Attitude and Heading Reference System (AHRS) needs a bit more data -- magnetometers and GPS sensors can help. Your question is a little vague as to what you're hoping to accomplish.
Here is an article describing some of the code you need in order to do this with quaternions, but in general there's not much I can suggest besides searching for "IMU attitude estimation".