function x=fixedpoint(f,xmin,xmax,x0,varargin) %FIXEDPOINT Fixed point iteration. % X=FIXEDPOINT(F,XMIN,XMAX,X0) returns the fixed point X of the map % F of the interval [XMIN,XMAX] to itself for starting guess value X0, and % plots the corresponding cobweb diagram. % X=FIXEDPOINT(F,XMIN,XMAX,X0,P1,P2,...) passes the parameters P1,P2,... % to F. % Francisco J. Beron-Vera % $Revision: 1.0 $ $Date: 2006/09/05 11:52:25 $ clf x=linspace(xmin,xmax,100); plot(x,f(x,varargin{:}),'b'), hold on, disp('Press any key to continue.'), pause plot(x,x,':b'), pause plot([x0 x0],[0 f(x0,varargin{:})],'r'), pause k=0; x1=0; while abs(x1-x0)>eps*abs(x1) k=k+1; if k>25 warning('Tolerance not satisfied.') break end x=f(x0,varargin{:}); plot([x0 x],[x x],'r'), pause plot([x x],[x f(x,varargin{:})],'r'), pause x1=x0; x0=x; end hold of