function logdelay(a,b,x0,x1,n)
%
% logdelay.m - this MATLAB file solves the 
% discrete logistic equation with delay
%   x(i+1)=x(i)+x(i)*(a-b*x(i-1))
%Try:
%logdelay(.2,.0025,10,15,100)
%logdelay(.3,.0025,10,15,100)
%logdelay(.5,.0025,10,15,100)
%logdelay(1.05,.0025,10,15,100)
%logdelay(1.25,.0025,10,15,100)
%logdelay(1.275,.0025,10,15,100)
  
  
  if nargin<5
    n=100;
  end
  if nargin<4
    x1=15;
  end
  if nargin<3
    x0=10;
  end

% Initialize
x=zeros(n+1,1);
t=zeros(n+1,1);
x(1)=x0;
x(2)=x1;
tt(1)=0;
figure
axis([0 n 0 1.5*a/b])
hold on
box on
plot([0 n], [a/b a/b])
% Iterate the Logistic difference equation
for i=2:n
t(i)=i-1;
x(i+1)=x(i)+x(i)*(a-b*x(i-1));
plot(t(1:i),x(1:i),t(1:i),x(1:i),'o')
end

