function feigenbaum(stt,fin,stps,myfl); %(r parameter,start x,how many transients to ignore,no of iterations, list values=1 no=0) %myfl=1 also plots Lyapunov exponent % examples r=3+65/90+.018 gives period 5 r=3+65/90+.02 period 10 inside the period 5 window %3.6055 period 10 in the period 10 window. %example feigenbaum(3,4,1000,0) clf; %clear the current figure iters=300; lambda=zeros(stps); xi=zeros(1,iters*stps); %make xi, yi vectors 1 by iters*steps yi=xi; wb = waitbar(0,'Please wait...'); %make a wait bar so we cna see how long it will run stp=0; for r=stt:(fin-stt)/stps:fin % step through all the r values x=.1; curpos=floor(stp*iters); % set a position in xi and yi for the current iterations stp=stp+1; for i=1:iters x=myfn(r,x); %iterate away the transients if myfl lambda(stp)=lambda(stp)+log(abs(myder(r,x))); end end for i=1:iters x=myfn(r,x); % now iterate a set of x and y values ready for a scatter plot if myfl lambda(stp)=lambda(stp)+log(abs(myder(r,x))); end xi(curpos+i)=x; yi(curpos+i)=r; end waitbar((r-stt)/(fin-stt),wb) %update the wait bar end close(wb); %close the wait bar if myfl lambda=lambda/iters; end hold on %scatter(yi,xi,'r','MarkerSize',1); %do the scatter plot plot(yi,xi,'ok','MarkerSize',1); %do the scatter plot if myfl plot(linspace(stt,fin,stps),lambda,'r'); end hold off function myval=myfn(r,x) %here is the function myval=r.*x.*(1-x); %myval=r*x^2-r*x+1; %myval=r*exp(x); function myd=myder(r,x) %here is the derivative myd=r-2*r*x;