function [t, y] = explicitRungeKutta(f, n, Tstart, Tend, y0)

t = linspace(Tstart, Tend, n+1);
dt = t(2)-t(1);
y = zeros(length(y0),n+1);
y(:,1) = y0;
for i=1:n
    r1=f(t(i),y(:,i));
    r2=f(t(i)+0.5*dt,y(:,i)+0.5*dt*r1);
    r3=f(t(i)+0.5*dt,y(:,i)+0.5*dt*r2);
    r4=f(t(i)+dt,y(:,i)+dt*r3);
    y(:,i+1) = y(:,i) + dt/6 * (r1 + 2*r2 + 2*r3 + r4);
    t(i+1) = t(i) + dt;
end;
