Generalised Truth Tables
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 (2025). Generalised Truth Tables (https://www.mathworks.com/matlabcentral/fileexchange/36235-generalised-truth-tables), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |