function mandel(N, xnum, xmin, xmax, ymin, ymax) % Task 1: producing the num of samples to produce in y ynum = round(xnum * ((ymax-ymin)/(xmax-xmin))); % Task 2: producing equally-spaced numbers for x-pts and y-pts. xpts = linspace(xmin,xmax, xnum); ypts = linspace(ymin, ymax, ynum); % Task 3: create a grid of (x,y) points [xgrid, ygrid] = meshgrid(xpts, ypts); % Task 5: compute the matrix c filled with the complex numbers we've % defined c = [xgrid + ygrid *i]; % Task 6,7: iterate to find the function fC(z) = z^2+C z0 = 0 * c; z = z0; % Task 8: using counter to find out how many iterations it takes before % fC(z) diverges counter = 0*c; for k = 1:N z = z.^2 + c; smallones = (abs(z)<2); counter = counter + smallones; end % Task 9: displaying the matrix counter using the function imagesc imagesc(xpts,ypts, counter); % Task 10: copy and paste the "zoom_mandelbrot()" function from the lab % right up into a new m-file and run.