NumPtsX=500; % Number of points in the mesh for one axis MaxIts=30; % Maximum number of iterations x=linspace(-0.25,1.25,NumPtsX); y=linspace(-0.25,1.25,NumPtsX); [xtrans,ytrans]=meshgrid(x,y); T=zeros(NumPtsX,NumPtsX); % This matrix holds the escape times for i=1:NumPtsX fprintf('On iterate %d\n',i); for j=1:NumPtsX x=xtrans(i,j); y=ytrans(i,j); for k=1:MaxIts if x<0.5 & y<=0.5 Newx=2*x; Newy=2*y; elseif y<0.5 & x>0.5 Newx=2*x-1; Newy=2*y; else Newx=2*x; Newy=2*y-1; end x=Newx; y=Newy; if (x^2+y^2)>100 T(i,j)=k; break end end end end T=T(end:-1:1,:); colormap prism imagesc(T)