View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Elementary Cellular Automata

5.0 | 2 ratings Rate this file 76 Downloads (last 30 days) File Size: 2.57 KB File ID: #26929 Version: 1.1
image thumbnail

Elementary Cellular Automata


David Young (view profile)


12 Mar 2010 (Updated )

Simulates any 1D nearest-neighbour binary cellular automaton.

| Watch this File

File Information

There are 256 elementary cellular automata, where "elementary" means that there is a single row of cells, with binary values, and update rules that depend only on nearest-neighbour interactions. They are described at

Our artist in residence asked if anyone had a program that would generate the patterns produced by these simple automata. I said it would only take a few minutes to write one in Matlab. Here's the result. It demonstrates the use of sub2ind to write very compact code.

In this function, the width of the pattern (the length of the array of cells) may be restricted, in which case the 1D array is taken to be circular to determine the states of the end elements. Random noise may also be added to the processing if required.


This file inspired Eternal Time/Cellular Automata.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
01 Dec 2016 yuting zhou

28 Apr 2016 Sk Sarif

I want to do three states 1D 3 nbds CA. This code is for 1D, 2 States, 3 nbds. Can any one code it for me?

Comment only
04 Mar 2014 alaa

alaa (view profile)

15 Mar 2010 1.1

Arguments now checked using validateattributes instead of custom functions. Example added to comments.

Contact us