How to write this expression in matlab ? p ^ q ^ r

5 ビュー (過去 30 日間)
Mohamad
Mohamad 2013 年 10 月 14 日
回答済み: Jan 2013 年 10 月 14 日
I do know that p ^ q is and(p,q) . But not sure what p q and r is
Thank you

回答 (3 件)

Jos (10584)
Jos (10584) 2013 年 10 月 14 日
p^q^r
p = true ; q = true ; r = false ;
tf = p && q && r
help and
  1 件のコメント
Mohamad
Mohamad 2013 年 10 月 14 日
Well no cause I am looking to have a truth table of 1 and 0.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2013 年 10 月 14 日
[P, Q, R] = ndgrid([0 1]);
truthtable = P & Q & R;
[P(:), Q(:), R(:), truthtable(:)] %display it

Jan
Jan 2013 年 10 月 14 日
Or perhaps:
for p = [false, true]
for q = [false, true]
for r = [false, true]
result = p & q & r;
disp([p, q, r, result])
end
end
end
This is Walter's solution broken down to simple loops.

カテゴリ

Help Center および File ExchangeFunctions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by