For starters, probably shouldn't use inline. Use an anonymous function instead. And I'm going to change the variables involved to be consistent with Matlab's definitions.
randGamma = @(n,lamda) (-sum(log(rand(1,n)))./lamda);
But the bigger problem is that randGamma, as defined, only generates a single output for inputs n and a. Won't you have to call it many times to generate the samples you seek?
Did you really mean that the gamma-distributed random variable is supposed to be the sum of 10000 exponentially-distributed random variables?
Let's assume that random variable G is the sum of 10 i.i.d random variables with exponential distribution with mean 2
Now generate an array of G using randGamma and using exprnd
G1(ii) = sum(exprnd(mu,1,n));
G2(ii) = randGamma(n,lamda);
Now compare the experimental and exact CDFs