% Mandelbrot set drawing, using MATLAB tricks % so it should be faster than mandel.m z0 = input('Please enter lower left corner -> '); z1 = input('Please enter upper right corner -> '); x0 = real(z0); y0 = imag(z0); x1 = real(z1); y1 = imag(z1); maxsteps = input('Please enter escape time -> '); hres = input('Please enter horizontal resolution -> '); vres = ceil( abs( hres * (y1-y0)/(x1-x0)) ); dx = (x1-x0)/hres; dy = (y1-y0)/vres; [X,Y] = meshdom(x0:dx:x1, y0:dy:y1); c = X + Y*i; z = c; pict = 0*z; clear X Y for k=1:maxsteps bigs = find(abs(z)>=2); pict(bigs) = k*ones(size(bigs)); z(bigs) = zeros(size(bigs)); c(bigs) = zeros(size(bigs)); z = z.^2 + c; end; image(flipud(pict)) axis('image') axis('xy') axis('off') % uncomment exactly one of the following lines: %colormap(gray(maxsteps)) % for gray-scale monitors colormap(hsv(maxsteps)) % for color monitors