I am trying to preallocate memory for the below program to increase the speed of computation.
global k1 k2 k3 k4 k5
k1=50;
k2=2.0e+03;
k3=5e+01;
k4=.0001;
k5=200;
dt=0.0001;
x(1)=0.9999;
y(1)=0.38462;
z(1)=0.1995;
t(1)=0.0;
for i=1:100000
t(i+1)=t(i)+dt;
x(i+1)=x(i)+dt*(-k5*(k1+k3)*x(i)+ k3*x(i)*z(i) + k4*z(i) + k2*y(i) );
y(i+1)=y(i)+dt*(k1*x(i) - k2*y(i));
z(i+1)=z(i)+dt*(-k3*x(i)*z(i) - k4*z(i) + k3*k5);
end
%plot(t,x,'b');
%plot(t,y,'g');
plot(t,z,'r');
%plot3(x,y,z);
%legend('x','y','z');
%hold on;
grid on;
%axis([0 10 0 10 0 10]);
%end
Kindly help. Thanks in advance.