%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% plog
%%
%% Make a plot of the iterates of the discrete logistic map
%%
%%  x_{n+1} = lambda * x_n * (1-x_n)
%%
%%    plog( lambda, x0, N, n)
%%
%%    lambda: the value of the logisitic parameter
%%      x0:   initial iteration value
%%       N:   Number of iterations to compute
%%       n:   (optional) just plot the last 'n' iterates
%%
%%   Returns:  The computed iterations.
%%
function x=plog(lam,x0,N,n)
  if ~exist('n')
    n=N-1;
  end
  x = zeros(1,N);
  f=@(s) lam*s*(1-s);
  for k = 1:N
    x(k) = x0;
    x0 = f(x0);
  end
  x = x(N-n:N);
  plot(x,'.')
end
