When I run this code in this line
x(xx)=x(t)+delT*(alpha+beta*log(a(t))+gama*x(t))*(M-x(t))*exp(-d*p(t))*exp(h*q(t))
because in the second time the loop gets executed, it want to have a(2), but a is still 1x1.
Why THAT is it is up to you, as I don't know what you want to achive.