Not sure where the post went that asked for "matlab[sic] implementation of inverted pendulum", but here's a link to a Michochip App Note that is all about implementing an inverted pendulum:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en021807
Have fun!
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en021807
Have fun!