% this function uses Euler's method to solve the Logistic Equation
function R = Logistic(tmax,N,k,b,R0)
%when calling this function, you need to pass the maximum time (tmax),
%the number of time steps (N), the parameters K and b, and the initial 
%population (y0).
dt = tmax/N; %this determines the size of the time step h
R = zeros(1,N+1); %define an empty population vector
R(1) = R0; %set the first value in the population vector to the inital pop.
for n = 1:N %this is the iterative loop for Euler's Method
    R(n+1) = R(n) + (k*R(n)*(1 - (R(n)/b)))*dt;
end %end the for loop
t = linspace(0,tmax,N+1); %this is used only for the plotting
plot(t,b*ones(size(t)),'LineWidth',2)%this plots a horizontal line
hold on
plot(t,R)%plots R(t)
ylabel('R (Rabbits)'), xlabel('Time (months)'), title('Rabbits and more Rabbits')
axis([0,tmax,0,b+1000])%sets the limits on the axes
