% julia sets (SLOW) 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; pict = zeros(hres+1,vres+1); for a = 1:hres+1, for b=1:vres+1 z = x0 + a*dx + (y0 + b*dy)*i; count = 1; while(abs(z) <= 2) if count >= maxsteps count = 0; break; end; z = z^2 + c; count = count + 1; end; pict(a,b) = count; end;end; image(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