function iterp3(f,r,N,N0)
% m-file to test iterative maps: implements cobweb construction,
% eliminating transients, for general maps
% Here one should pass a function handle to the function f = f(x,r), which
% takes an argument x and a parameter r, and should be specified in an
% m-file f.m .
% Usage example: iterp3(@f,2,40,20)
%
yy = 0:0.05:1; 
figure(1) ; clf ; 
plot(yy,feval(f,yy,r),'-',yy,yy,'--')
hold on
Xn = [];
x = 0.3;          % Initial value
Xn = [];
%r = 2;           % Bifurcation parameter
for i = 1:N0      % Eliminate transients - first N0 steps
    x1 = feval(f,x,r);
    x = x1;
end
%plot([x x],[0 x],'r-')  % First line, to get to diagonal
for i = 1:N
    x1 = feval(f,x,r);
    Xn = [Xn x1];
    plot([x x],[x x1],'r-',[x x1],[x1 x1],'r-')
    x = x1;
end
axis([0 1 0 1])
hold off