function n = may(startr,endr,stepr, k, n0, nostep,singleplot,animation) % animated plotting of a time series of the May's equation (if singleplot>0) % plus the final plot of N against r (bifurcation plot) %startr,endr,stepr - minimum, maximum growth rate and difference between adjacent values %k - carrying capacity %n0 - initial population size %nostep - number of steps for simulation % singleplot == 0: no plot except the bifurcation diagram % singleplot == 1: N against time % singleplot == 2: state space % animation - whether to animate startstep =min(50,nostep-1); if startr >= endr | stepr<=0 return; end dots=[]; for r=startr : stepr : endr a=maysingle(r,k,n0,nostep); dots=[dots; a(startstep:nostep)]; if singleplot==1 refresh; plot(1:nostep+1,a); axis([1 nostep+1 0 k*2]); title(r); pause(animation); elseif singleplot==2 parabolasingle(r,k,n0,nostep,endr); pause(animation); end end figure; plot(startr : stepr : endr,transpose(dots),'.','MarkerEdgeColor','b','MarkerFaceColor','b','MarkerSize',2);