p=0.5;h=0.01;dpdt= @(t,p) (kmax)*(1/(K+(1/p)));p_plot=zeros(0,10000);t=0:h:100;for t=0:h:100 k1=dpdt(t,p); k2=dpdt(t+(h/2), p+(h*k1/2)); k3=dpdt(t+(h/2), p+(h*k2/2)); k4=dpdt(t+h, p+(h*k3)); p=p+((1/6)*(k1+(2*k2)+(2*k3)+k4)*h) p_plot=[p,t];end
MATLAB: I cant put the loop output in a matrix format. I want to put the loop output (p) as a vector or matrix in order to plot all the outputs later.
loop outputmatricesvectors
Best Answer