kk=4000; y=zeros(1,4000); y(1)=0.5678; figure('Position',[50,50,800,500]); p=plot(2.8,-3.0,'EraseMode','none', 'Color', 'red'); xlim([2.80,4.00]); ylim([-3.00,1.00]); xlabel('r-value','FontSize',12); ylabel('Lyapunov Exponent','FontSize',12); title('Logistic Map','FontSize',12); for r=2.8000:0.0001:3.9999; for j=2:kk; y(j)=r*y(j-1)*(1-y(j-1)); end x=y(2001:4000); term=log(abs(r*(1.0-2.0*x))); total=sum(term)/length(term); set(p,'XData',r,'YData',total); drawnow; end hold on; plot([2.8,4.0],[0.0,0.0],'-b','EraseMode','none'); hold off;