%This function plots dynamics and lines using Levins's equation together function metapop_plot(imi,ext,ini,alfa,dim,nostep, animation) % imi - immigration rate % ext - extinction rate % ini - proportion of habitats initially occupied (0 - one individual in the centre) % alfa - shape constant for the rescue effect (if == 0 -> standard Levins's equation) % dim - number of rows of cells (dim^2 is the number of habitats) % nostep - number of simulation steps %animation - whether to animate start=min(100,nostep/2); scale=0.1; metapop_lines(imi,ext,alfa); y=metapop(imi,ext,ini,alfa,dim,0, nostep); if (animation > 0) for i=1:nostep-1 plot([y(i),y(i+1)],[0.01,0.01],'g.'); pause(0.1); end else plot(y,0.01.*ones(nostep),'g.'); end %[n x]=hist(y(start:nostep)); %n=scale.*n./sum(n); %bar(x,n)