%predator prey model
function [t,yprey,ypred] = predprey(y0prey,y0pred, totaltime, steps, growthrate, starverate, predrate, c)
%These are the coupled differential equations that govern this model
%drabbit/dt = growthrate*rabbit - predrate*rabbit*wolf
%dwolf/dt = -starverate*wolf + c*rabbit*wolf

t = linspace(0,totaltime,steps); %create array of time steps
yprey(1) = y0prey;
ypred(1) = y0pred;

%use euler method and step forward in time
for i = 2:steps
    
    dt = totaltime/steps;
    yprey(i) = yprey(i-1) + dt*(growthrate*yprey(i-1) - predrate*yprey(i-1)*ypred(i-1));
    ypred(i) = ypred(i-1) + dt*(-starverate*ypred(i-1) + c*yprey(i-1)*ypred(i-1));
end

end

