Nice not to have to do this myself. But your variable naming is a little confused in the file - in the source, you call theta beta. It's fine in the documentation, though, which is more important, I guess.
It saves me when I am trying to use gamma distribution in Embedded Matlab. Since gamma distribution is not supported, I must generate the rv by myself. When coding in Embedded Matlab, the only thing needs to be modified is to assert a bound for "un" as follows:
assert (k <= 10000);
un = rand(1,k);
g = (theta)*(g - sum(log(un),2));