% First of all select a range for the complex number C.
xi=-2;yi=-1;xj=0.5;yj=1;
% Define b x h grid of points.
b = 1024; h = 768;
% Now distribute the complex number C over the grid defined.
x = xi:(xj-xi)/(b-1):xj; y = yi:(yj-yi)/(h-1):yj;
% Grid of complex points.
[x,y] = meshgrid(x,y);
c = x + i*y;
z=zeros(h,b);
% Select the number of iterations.
iter = 100;
% Evaluate the (Z2 + C).
for k = 1:iter
z = z.*z + c;
end;
mandel = ones(h,b);
% If the point is in the Mandelbrot set.
mandel = mandel + ( abs(z) < 2 );
mandel = flipud(mandel);
% Define and plot the color map. This is for blue and black.
map = [ 0 0 0; 0 0 1 ];
image(mandel), colormap(map), axis off;