Your code runs fine and it is clean. It can be simplified, but the application of the index a is valid. I'm not sure why your teacher sees a problem.
A faster version:
Pi = "Can't perform estimate";
noPointsInCircle = sum(d < r^2);
Pi = 4 * (noPointsInCircle/n)
d < r^2 is a logical vector. The TRUE is treated as 1, the FALSE as 0. So the sum does exactly what your FOR loop does, but much faster.