clear
fx='r*x*(1-x)';
axis([2.8 4 -0.1 1.1]);
hold on
xlabel('{\rho}','Fontsize',12)
ylabel('{\it x}','Fontsize',12)
title('Bifurcation diagram of the logistic equation','Fontsize',12)
grid
for r=2.8:0.001:4
x=0.1;
for i=1:200
f(i)=eval(fx);
x=f(i);
end
h5=plot(r,f(200),'erasemode','none');
drawnow
x=f(200);
for i=1:200
f(i)=eval(fx);
x=f(i);
set(h5,'xdata',r,'ydata',f(i));
drawnow;
end
end