Sierpinski Sponge

Generates the Sierpinski Sponge.
Updated 4 Jun 2003

No License

The Sierpinski Sponge is a fractal image based on the Cantor Set. Cantor's fractal is based on a removing the middle third of a line segment, resulting in two new line segments of equal length. The middle third of these two segments is then removed, resulting in four new line segments.

The process is repeated to the desired level of iterations. The Sierpinski Carpet, a two-dimensional version of the Cantor Set, starts with a square. The Square is divided into nine equal sized squares and the middle square is removed for the first iteration. Then the remaining eight squares are each divided into nine squares, and the middle square is again removed for the second iteration.

The Sierpinski Sponge is the three-dimensional extrapolation of the carpet. The fractal image starts with a cube. The cube is then divided into twenty-seven equal sized cubes, and the center cube and the middle cube of each face is removed, leaving only the cubes on edges and corners. This is the first iteration. The process is applied to the remaining twenty cubes for the second iteration, and so on.

The Sierpinski Sponge is a fractal with some unique properties. Like the Sierpinski Gasket, as the level of iterations approaches infinity, the area of the sponge approaches zero, while the perimeter approaches infinity. This is because with each iteration new edges are added and volume is removed.

Cite As

Moses Boone (2024). Sierpinski Sponge (, MATLAB Central File Exchange. Retrieved .

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

Inspired by: ClassicalFractals.m

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes