%this function uses Euler's method to solve the logistic equation
function [y,t] = FermentEulers(tmax,N,r,M,y0)
%when calling this function, you need to pass the maximum time to run the
%simulation (tmax),
%the number of time steps (N), the parameters r and M, and the initial 
%population y0.
dt = tmax/N; %this determines the size of the time step h
y = zeros(1,N+1); %define an empty vector of yeast concentrations
y(1)=y0;
for n = 1:N %this is the iterative loop for Euler's Method
y(n+1) = y(n) + r*y(n)*(1 - (y(n)/M))*dt;
end %end the for loop
t = linspace(0,tmax,N+1); %this is used only for the plotting
h1 = figure;%provide a handle for first figure (yeast)
%the code below is strictly used for plotting
figure(h1);
plot(t,y)
ylabel('Yeast'), xlabel('Hours'), title('Euler''s Method Example')

