I thought I would post some code I just wrote that implements the Bethe-Bloch slowing formula in MATLAB. The main program is protonstopping.m, which shows how the underlying functions can be used. In particular, you can obtain PDG range and loss rates in several ways.
As always with research software, you should use this code at your own risk, i.e. you should check its validity against your particular needs.
Code is here (.zip archive).