function iterp2(f,r,N)
% m-file to test iterative maps: implements cobweb construction, including
% transients, for a general map f(x,r) with a parameter r
% The function argument f = f(x,r) should be passed via a function handle,
% and should be defined in a function m-file f.m 
% Usage example: iterp2(@f,2.4,30)
%
yy = 0:0.05:1; 
figure(1) ; clf ; 
plot(yy,feval(f,yy,r),'-',yy,yy,'--')
hold on
x = 0.3;          % Initial value
Xn = [];
%r = 2;           % Bifurcation parameter
x1 = feval(f,x,r);
plot([x x],[0 x1],'r-',[x x1],[x1 x1],'r-')  % First line, to get to function
x = x1;
for i = 2:N
    x1 = feval(f,x,r);
    Xn = [Xn x1];
    plot([x x],[x x1],'r-',[x x1],[x1 x1],'r-')
    x = x1;
end
hold off