Vex Pendulum White paper and Matlab Simulation Code

I’ve had a few requests for this link. It was buried in a long vex pendulum thread so I have reposted it here:

Scroll to the bottom of this link.
Feel free to use it and please provide any corrections or comments to me.

Key Words: Balance robot pendulum gyro matlab simulation octav accelerometer inverted tilt angle complementary filter