How can I establish a logical expression from given truth table using MATLAB?
Show older comments
I have a given truth table with input and correspomding output. Then what is the process to establish a logical expression (eg: AB+C'B') from the given truth tabe with MATLAB code.
1 Comment
Stephen23
on 2 Jun 2022
Note that there are infinitely many logical expressions which will generate a given truth table. Which one do you want?
Answers (2)
KALYAN ACHARJYA
on 6 Feb 2022
Edited: KALYAN ACHARJYA
on 6 Feb 2022
#For Matrix Multiplication
out=A*B+C'*B';
#For Array Multiplication
out=A*.B+C'*.B';
Stephen23
on 14 Oct 2026
You could use my Espresso wrapper:
which returns a simplified logic table (0=false, 1=true, 2=don't care) and a symbolic expression:
>> A = [0,0,0,0,1,1,1,1];
>> B = [0,0,1,1,0,0,1,1];
>> C = [0,1,0,1,0,1,0,1];
>> output = [1,1,1,0,0,0,1,1];
>> [indOut,depOut,expr] = matEspresso([A(:),B(:),C(:)],output(:))
indOut =
3×3 int8 matrix
2 1 0
0 0 2
1 1 2
depOut =
3×1 int8 column vector
1
1
1
expr =
'Z = (B & ~C) | (~A & ~B) | (A & B)'
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!