Code covered by the BSD License  

Highlights from
Mandelbrot set with the parallel computing toolbox

image thumbnail

Mandelbrot set with the parallel computing toolbox

by

 

Example of using parallel computing to make the most of the mandelbrot set

Z=mandel1(maxiter,steps,xmin,xmax,ymin,ymax,tasks)
function Z=mandel1(maxiter,steps,xmin,xmax,ymin,ymax,tasks)
%maxiter
%steps
%tic
%steps=1000;
%maxiter=1000;
%xmin=-2;
%xmax=2;
%ymin=-2;
%ymax=2;
%tic
     %Z=zeros(steps/steps);
     dy=(ymax-ymin)/((steps-1)/tasks);
     dx=(xmax-xmin)/((steps-1));
     for m=1:steps/tasks
         ci=single(ymin+dy*m);
         for n=1:steps
            cr=single(xmin+dx*n);
            zr=single(cr);
            zi=single(ci);
            rmax=maxiter;
            for r=0:maxiter
                zrn=single(zr*zr-zi*zi+cr);
                zin=single(2*zi*zr+ci);
                zi=single(zin);
                zr=single(zrn);
                if single(zr*zr+zi*zi)>10000,
                    rmax=r;
                    break
                end
            end
            Z(m,n)=rmax;
 
         end
    end
    %colormap(hsv(maxiter));
    %Z=sqrt(Z/maxiter);
    %imagesc(Z)
    %axis off
    %axis equal
%toc
end

Contact us