% Logistic Example - Simulation
clear
xlab = '$n$'; 		
ylab = '$p_{n}$'; 		
mytitle = 'Simulation for Logistic Model'; 

n = 0:50;
pnr1(1) = [50]; pnr2(1) = [50]; 
pnr3(1) = [50]; pnr4(1) = [50];
for i= 1:50
    pnr1(i+1) = 1.5*pnr1(i) - (0.5/1000)*pnr1(i).^2;
    pnr2(i+1) = 2.85*pnr2(i) - (1.85/1000)*pnr2(i).^2;
    pnr3(i+1) = 3.3*pnr3(i) - (2.3/1000)*pnr3(i).^2;
    pnr4(i+1) = 3.65*pnr4(i) - (2.65/1000)*pnr4(i).^2;
end

plot(n,pnr1,'b-','LineWidth',1.5);
hold on
plot(n,pnr2,'r-','LineWidth',1.5);
plot(n,pnr3,'-','color',[0,0.5,0],'LineWidth',1.5);
plot(n,pnr4,'m-','LineWidth',1.5);

grid
text(8,220,'$p_{n+1} = p_{n} + rp_n\left(1 - \frac{p_n}{1000}\right)$',...
    'FontSize',14,'interpreter','latex');
l= legend({'$r = 0.5$','$r = 1.85$','$r = 2.3$','$r = 2.65$'},...
    'Location','Southeast');
set(l,'Interpreter','Latex');

xlim([0 50]);
ylim([0 1300]);
fontlabs = 'Times New Roman';   % Font type used in labels
xlabel(xlab,'FontSize',14,'FontName',fontlabs,'interpreter','latex');  
ylabel(ylab,'FontSize',14,'FontName',fontlabs,'interpreter','latex'); 
%title(mytitle,'FontSize',16,'FontName',fontlabs,'interpreter','latex'); 
set(gca,'FontSize',12);

print -depsc logsim_eg.eps