function [N,dim]=boxdim(num) %Computes the box dimension of the Henon Attractor %Use a grid with 2^num times 2^num points xmin=-2.0; xmax=2.0; step=2^num; epsilon = (xmax-xmin)/step Boxes=zeros(step+1); x=1.77; y=0.0; % first get rid of some transients for t=1:100, [x,y]=henon(x,y); end %now iterate and increment boxes array each time we land in one tmax = max(100000,10*step*step); %choose # of iterates for t=1:tmax, i=ceil((x-xmin)/epsilon); %which box are we in j=ceil((y-xmin)/epsilon); Boxes(i,j) = Boxes(i,j)+1; [x,y] =henon(x,y); end %contourf(Boxes) bmax = max(max(Boxes)); image(256*Boxes/bmax) % plot the matrix as an image & scale to colormap colorbar colormap(hot) % %Count the number of boxes filled N=0; for i=1:step, for j=1:step, if Boxes(i,j) > 0 N=N+1; end end end dim=-log(N)/log(epsilon);