
% Julia set
% Ricardo Carretero Mar'2003

Pc = inline('[z.^2+c]','c','z');
c=0.38+0.32*i;

Nx=850;
Ny=670;
x=linspace(-1.2,1.2,Nx);
y=linspace(-1.3,1.3,Ny);
[X,Y]=meshgrid(x,y);
z=X+i*Y;
leave=0*z;

Nitmax=256;
zmax=Nitmax;

colvec=jet(1*Nitmax);
colvec=colvec([1*Nitmax:-1:1],:,:);
colvec(1,:)=[0 0 0];
figure(1)
clf

for j=1:Nitmax
 z=Pc(c,z);
 out=abs(z)>zmax;
 z=z-out.*z;
 leave=leave+out*j;
  if(mod(j,10)==0)
  j
  figure(1)
  surf(X,Y,(leave/256).^(0.5));
  shading interp;
  colormap(colvec);
  view([0 90]);
  axis tight;
%  colorbar
  pause(0.0001)
 end
end

figure(1)
surf(X,Y,(leave/256).^(0.5));
shading interp;
colormap(colvec);
view([0 90]);
axis tight;
% colorbar
pause(0.0001)

