% julia sets, but programmed with MATLAB tricks c = input('Enter complex parameter -> '); if abs(c)>=2 disp('Warning: Using a parameter with absolute value') disp('greater than 2 is not recommended.'); end; 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); z = X + Y*i; c = c*ones(size(z)); 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