global s; s=0; y0=[ 0.01 0.01 ]'; for j=1:1000 options=odeset('AbsTol',1e-12); [t,y]=ode45('duffingp',[0,1],y0, options); [m,n]=size(y); y0=y(m,:)'; figure(1); axis([-2 2 -2 2]); hold on; plot(y(:,1),y(:,2),'r-', 'EraseMode','none' ); pause(0.1) plot(y(:,1),y(:,2),'b-', 'EraseMode','none' ); drawnow s=s+1; end