function mandelbrot15(any)
% RUN: 'mandelbrot15(1)' first to get the axes, then 'mandelbrot15' (no argument) after..
% .. but first zooming in using the zoom tool.
tic
if nargin==1
    %default axes
    x0=-2;x1=0.5;y0=-1;y1=1;
    axis([x0 x1 y0 y1])
end
k=axis; x0=k(1); x1=k(2); y0=k(3); y1=k(4);
clc
clf
num=440;
[x,y]=meshgrid( x0:(x1-x0)/(num-1):x1 , (y0:(y1-y0)/(num-1):y1)*i );
c=x+y;
z=zeros(num,num);
jvec=5:30:500;
jindex=1;
cmap=colormap(hsv(length(jvec)));
hold on
for j=1:max(jvec)
    z=z.^2+c;
    if jvec(jindex)==j
        if jindex<length(jvec)
            plot(real(~isnan(z).*c),imag(~isnan(z).*c),'.','Markersize',0.5,'Color',cmap(jindex,:))
        end
        clc
        jindex=jindex+1;
        perc=j/max(jvec)*100/2+(jindex-2)/length(jvec)*100/2;
        disp([int2str(perc) '% done'])
    end
end
plot(real(~isnan(z).*c),imag(~isnan(z).*c),'.','Markersize',0.5,'Color',[0 0 0])
axis([x0 x1 y0 y1])
xlabel('Real');
ylabel('Imaginary');
clc
toc

