Place both files: julia.m and juliatest.m in the same folder:
1 |
julia.m |
#{ Calculate a Julia set zmin = minimum value of c zmax = maximum value of c hpx = number of horizontal pixels niter = Number of iterations c = complex number #} function M = julia(zmin, zmax, hpx, niter, c) %% Number of vertical pixels vpx=round(hpx*abs(imag(zmax-zmin)/real(zmax-zmin))); %% Prepare the complex plane [zRe,zIm]=meshgrid(linspace(real(zmin),real(zmax),hpx), linspace(imag(zmin),imag(zmax),vpx)); z=zRe+i*zIm; M=zeros(vpx,hpx); %% Generate Julia for s=1:niter mask=abs(z)<2; M(mask)=M(mask)+1; z(mask)=z(mask).^2+c; end M(mask)=0; end
1 |
run juliatest.m |
Jc1=julia(-1.6+1.2i, 1.6-1.2i, 640, 128, -0.75+0.2i); imagesc(Jc1) axis off colormap(turbo) end
Recent Comments