Shu-An - when I run your code, I see the following error
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is
a scalar. To perform elementwise matrix powers, use '.^'.
y = ((30^x)*exp(-30))/factorial(x);
If you do an elementwise operation, try changing your y assignment to
y = ((30.^x)*exp(-30))./factorial(x);