
s=0.2;  % defines s
N=100;  % defines N
p=zeros(N,1); % p stores the output of the model in a column vector with N 
elements
p(1)=0.001; %this determines the initial frequency
for n=1:N-1 % this starts a do loop that iterates the model for next N-1 
generations
    p(n+1)=p(n)+s*p(n)*(1-p(n))^2/(1+s*p(n)*(2-p(n))); %defines density in 
the next generation
end % ends the do loop

plot(p) %plots the data
xlabel('generation'); %puts label on x axis
ylabel('allele frequency'); %puts label on y axis
