clear all
global r
%solving logistic with Euler
r=1;
delta=0.01;
T=8;
Nt=ceil(T/delta);%floor
X=linspace(0.01,2,21);

for ia=1:length(X);

x0=X(ia);
x=zeros(Nt,1);t=x;

x(1)=x0;
t(1)=0
for it=2:Nt
    t(it)=(it-1)*delta;
    x(it)=x(it-1)+delta*xdot(x(it-1),t(it-1));
end;

xan=r./(1+((r-x0)/x0)*exp(-r*t));

figure(10)
plot(t,x,'b','linewidth',2,'markersize',16)
%plot(t,x,'b',t,xan,'r','linewidth',2,'markersize',16)
hold on
plot(t,r*exp(0*t),'--r')
xlabel('$t$ ','FontSize',24,'Interpreter','latex');
ylabel('$x(t)$ ','FontSize',24,'Interpreter','latex');
set(gca,'Fontsize',24)
grid on
%hold off

% 
% figure(11)
% semilogy(t,abs(x-xan),'r','linewidth',2,'markersize',16)
% xlabel('$t$ ','FontSize',24,'Interpreter','latex');
% ylabel('$|x(t)-x_{an}(t)|$ ','FontSize',24,'Interpreter','latex');
% hold off

end
plot(t,r/2*exp(0*t),'--r')
figure(10);hold off



