Generalised Truth Tables

Generate 'truth tables' where columns correspond to digits in arbitrary mixtures of bases.

You are now following this Submission

Normal truth tables enumerate all possible rows of binary digits. In a generalised truth table, the base associated with each digit is arbitrary. This allows exhaustive generation of combinations of variables of heterogeneous cardinality; e.g. we might consider every possible combination of hair and eye colour, using hair colours in {black, brown, blonde, grey, red} and eye colours in {brown, blue, green, grey}. Using TTABLE([5 4]); would generate a 20-by-2 matrix, where each row corresponds to a hair & eye combination.

Generalised truth tables can also be seen as computing counting digits where each place has an arbitrary base;
TTABLE([10 10 10]) - 1 would generate rows from [0 0 0] to [9 9 9], but we could also use TTABLE([10 5 10]) - 1 to indicate that the second digit is counted in base 5 instead of base 10.

Normal K-bit truth tables can be produced with TTABLE(ones(1, k) * 2) - 1.

Additional documentation is included.

Cite As

Richard Stapenhurst (2026). Generalised Truth Tables (https://www.mathworks.com/matlabcentral/fileexchange/36235-generalised-truth-tables), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0