Fractal generator

Function to generate fractal structures Excellent for educational demonstrations.
Updated 18 Nov 2009

View License

Based on axioms and generators the function generates fractal structures of a specified level and one of the predefined geometries (Sierpinski's triangle and pyramide and Menger's sponge).

Works in two ways: 1) Generation of one of the three
predefined geometries or 2) Alternative the axiom and generator coordinates may be specified to generate other fractal than those predefined.

Usage (for predefined use):
where N is the level and s=1/2/3

fractal(2,1); % show the Sierpinski's triangle with 2 levels.
fractal(0,3); % show the axiom of the Menger's sponge.
fractal(1,3); % show the generator of the Menger's sponge.

Cite As

Jakob Laugesen (2024). Fractal generator (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Fractals in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes