Generalised Truth Tables

Generate 'truth tables' where columns correspond to digits in arbitrary mixtures of bases.
255 Downloads
Updated 17 Apr 2012

View License

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 (2024). Generalised Truth Tables (https://www.mathworks.com/matlabcentral/fileexchange/36235-generalised-truth-tables), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Logical 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
1.0.0.0