% % ratecon.m - this MATLAB file illustrates the concept of the % rate constant for the differential equation % N'(t) = k (Neq - N(t)) % by prompting the user to give a range of rate constants % and an initial value and plotting the trajectories for % 5 rate constants over the given range % !c: Neq=input('input equilibrium Neq: ') N0=input('input initial population N0: ') klo=input('input low value for rate constant k: ') khi=input('input high value for rate constant k: ') n=input('end of time interval T: ') x=zeros(n,1); t=zeros(n,1); for j=1:5 k=klo+(khi-klo)*.25*(j-1); for i=1:n t(i)=i-1; x(i)=Neq-(Neq-N0)*exp(-k*t(i)); end; plot(t,x);pause end; title('graph with varying k values'),pause s=input('Do you want to stop - if so enter 0') end