The Mandelbrot set is a set of complex numbers C where z_n+1 = z_n^2 + c (z_0 = 0) does not diverge for all c in the set C. The image is generated by calculating the number of iterations until |z_n| is larger than a certain escape radius. Of course, since some points will never diverge, a limit of the number of iterations is required.
The function used for the Julia set is the simple monic quadratic function. This Julia set is similar to the Mandelbrot set in that it uses a similar form. But, this time, it is the set of complex numbers C where z_n+1 = z_n^2 + d does not diverge for all c in the set C given that z_0 = c. The variable d is constant and complex.
To plot the sets, the viewer uses a set of datapoint as c in the Mandelbrot set case, or z_0 in the Julia set case, and generates a color for each datapoint that depends on the number of iterations needed for divergence.
With this code, you can zoom in up to 1E10x and out, and pan around as if viewing a regular plot. After each zoom or pan action, the set is recalculated given the new plot boundaries view using a C subfunction (a matlab subfunction is also provided).
To view the Mandelbrot using default settings, simply run main(). For the Julia set, use main('FractalType','Julia').
The function main also accepts other Parameter-Value pairs. For the list of all properties, see the function header.
Future additions include adding a GUI to change the maximum number of iterations.
Christopher (2022). Interactive fractal viewer for the Mandelbrot and Julia sets (https://www.mathworks.com/matlabcentral/fileexchange/29118-interactive-fractal-viewer-for-the-mandelbrot-and-julia-sets), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Inspired by: Mandelbrot set vectorized
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!