function [tTrace,y1,yana] = euler(t0,y0,dt,nSteps)

% use e.g. [tTrace,y1,yana] = euler(0,0.1,0.1,1500);
% plot(tTrace,y1)
% plot(tTrace,y1-yana)


y1 = zeros(1,nSteps);
tTrace = zeros(1,nSteps);

t = t0;
y = y0;

for k=1:nSteps
    
    k1 = rkFunc(t,y);
    
    y = y + dt*k1;
    
    t = t+dt;

	tTrace(k) = t;
	y1(k) = y(1);
end
   
% add initial condition to vector

y1 = [y0 y1];
tTrace = [t0 tTrace];
    
r = 0.1;
K = 13;

% analytical solution

yana = y0*exp(r*tTrace)./(1+y0/K*(exp(r*tTrace)-1));


end

function yPrime = rkFunc(t,y)

r = 0.1;
K = 13;

yPrime =  r*y*(1-y/K);

end