Your signature of the derivative function is f2(A,C,t) not f2(A,t,C). So these lines:
k6(k) = dt*f2((A(k)+0.5*k1(k)),t(k)+0.5*dt,C(k)+0.5*k5(k));
k7(k) = dt*f2((A(k)+0.5*k2(k)),t(k)+0.5*dt,C(k)+0.5*k6(k));
k8(k) = dt*f2((A(k)+k3(k)),t(k)+dt,C(k)+k7(k));
should probably be these instead:
k6(k) = dt*f2((A(k)+0.5*k1(k)),C(k)+0.5*k5(k),t(k)+0.5*dt);
k7(k) = dt*f2((A(k)+0.5*k2(k)),C(k)+0.5*k6(k),t(k)+0.5*dt);
k8(k) = dt*f2((A(k)+ k3(k)),C(k)+ k7(k),t(k)+ dt);
Best Answer