function []=Pure_Games(W,s,MaxT) % % Pure_Games(W, s0, MaxTime) % where W is a 2x2 matrix of the payoff to the two strategies. % s0 is the initial ratio of strategy 1 in the population % MaxTime is the duration of the dynamics. % if nargin<3 MaxT=100; if nargin<2 s=1e-3; if nargin<1 W=[1 0; 1.5 0.7]; end end end [T P]=ode45( @(t,y)diff_equations(t,y,W), [0 MaxT], s); subplot(2,1,1); plot(T,P,'k','linewidth',1); xlabel 'Time' ylabel 'Proportion of strategy s in population' subplot(2,1,2); h=plot(T,P.*P*W(1,1)+P.*(1-P)*W(1,2)+(1-P).*P*W(2,1)+(1-P).*(1-P)*W(2,2),'b','LineWidth',1); xlabel 'Time' ylabel 'Mean population payoff' end function [ds]=diff_equations(t,s,W) ds=s*(1-s)*(s*W(1,1)+(1-s)*W(1,2) - s*W(2,1) - (1-s)*W(2,2)); end