Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Mandelbrot Explorer, V1.0
- % Sean Irby, November 25th, 2015
- %Function for Choosing a Point
- clc;
- %Chart Initiator
- % These numbers set the bounds of the calculation. The mandelbrot set is
- % contained within (-2, 1) in x and +/- sqroot 2 in i*y.
- xmin = -2;
- xmax = 1;
- ymin = -1.44;
- ymax = 1.44;
- x = xmin;
- y = ymin;
- %Resolution / Iteration numbers;
- d = 0.01 ; %lower for better resolution
- N = 25; %Raise for better contrast
- Nx = abs(xmin/d) + xmax/d + 1;
- Ny = abs(ymin/d) + ymax/d + 1;
- Chart = [Ny;Nx];
- % pDeux calc scan, with a double-for loop that calculates every y for an x,
- % resets, y, increments x by one resolution point, then continues
- for Cx = 1:Nx
- for Cy = 1:Ny
- %initiates values for the mandelbrot calculation
- z = 0;
- zo = x+y*1i;
- A = 0;
- pDeux = 0; % or 1?
- j = 1;
- Stroobap = 0;
- %pDeux calc Loop; determines if a point is in the set and sets
- %pDeux to zero, or determines if it is out of set and records the
- %number of iterations to determine pdeux
- while (j <= N)
- z = (z^2)+zo;
- if (abs(z) > 2)
- pDeux = j;
- j = N + 1;
- Stroobap = 1;
- end
- j = j+1;
- end
- if Stroobap == 0
- pDeux = 0;
- end
- %Saves pDeux (number of iterations until divergance) as the
- %variable to plot in the chart, before incrementing y/x.
- Chart (Cy,Cx) = pDeux;
- Cy = Cy + 1;
- y = y + d;
- end
- y = ymin;
- Cx = Cx + 1;
- x = x + d;
- end
- Chart = Chart * 3 %improves contrast; for different values of N, the magic interger should change
- image(Chart); %Isn't MATLAB easy to plot things with? ;)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement