File Exchange

image thumbnail

Sierpinski-Menger sponge

version 3.0 (36.6 KB) by Mathworlds
Function to compute, display, and save the Sierpinski-Menger fractal sponge, at any iteration / depth level. 3D printable ready option.

1 Download

Updated 18 Nov 2020

From GitHub

View Version History

View license on GitHub

Please first check the examples tab (.mlx doc) here on the right for a complete description.

Once downloaded, typewrite 'doc Menger_sponge' or 'help Menger_sponge' in Matlab console for support.

To benefit from the file documentation attached, be sure to download the file, not to just copy and paste it.

Cite As

Mathworlds (2021). Sierpinski-Menger sponge (, GitHub. Retrieved .

Comments and Ratings (5)


Write and save the vertex V and the face sets T (in a .ply or .stl file for instance) before sending it to your favorite 3D printing manufacturer. Such file format writer is not included here, but may easily be found on this file exchange.


Display function based on fill3 is still very greedy in cpu time as well as the number of faces very quickly grows. From nb_iterations >= 3 it becomes very slow to get a display. My advice is to save V and T, to write a file and then to use another 'way' to display it (with a more efficient 3D display engine).


New version is now available.




New version is coming for 3D printing. Waiting for it, to prevent from creating non manifold edges, just comment lines relative to remove duplicated vertices and triangles (l121-123).

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!