필터 지우기
필터 지우기

Matlab simplify boolean expression

조회 수: 41 (최근 30일)
ket
ket 2012년 5월 27일
댓글: Ibrahim Elewah 2022년 6월 26일
I want to simplify a boolean algebra expression. I have taken this example from matlab online help but it does not work:
simplify((a and b) or (a and (not b)), logic)
Any suggestion?
I am using matlab R2012a (7.14.0.739)

답변 (3개)

Geoff
Geoff 2012년 5월 27일
The expression:
(A && B) || (A && ~B)
Is logically equivalent to:
A
The reason is that both terms require A to be true, and the whole expression evaluates to true regardless of whether B is true or false. If you drew up a truth table for this, it'd be immediately obvious.
[EDIT] Hadn't clicked that the poster was talking about the symbolic math toolbox.
syms a,b;
simplify( (a & b) | (a & ~b) )
  댓글 수: 3
Geoff
Geoff 2012년 5월 28일
Cheers.. I should stop answering outside my area of experience. =)
Oleg Komarov
Oleg Komarov 2012년 5월 28일
But that's how you learn new things!

댓글을 달려면 로그인하십시오.


Alexander
Alexander 2012년 5월 29일
You have copied a MuPAD command. Did you use it inside a MuPAD Notebook? If not, type this at the MATLAB command prompt:
mupad
This will open a MuPAD Notebook. There, paste the input near the bracket (red text should appear) and press enter:
[ simplify((a and b) or (a and (not b)), logic)
a
If you don't want to open a MuPAD notebook, try this in MATLAB:
evalin(symengine, 'simplify((a and b) or (a and (not b)), logic)')
Though if you prefer to stay in MATLAB, you should take what Geoff suggests:
syms a b;
simplify((a & b) | (a & ~b))
(For some reason it did not work for me with the comma between a and b).
  댓글 수: 2
ket
ket 2012년 5월 29일
Very comprehensive answer. Thanks!
Ibrahim Elewah
Ibrahim Elewah 2022년 6월 26일
Thank You @Alexander

댓글을 달려면 로그인하십시오.


ket
ket 2012년 5월 27일
Ok, but how do use matlab to simplify a boolean expression? Also, it there a method where I can see the intermediate steps?
  댓글 수: 1
Geoff
Geoff 2012년 5월 28일
I don't have the symbolic math toolbox.. Does this work?
syms a,b;
simplify( (a & b) | (a & ~b) )

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Utilities for the Solver에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by