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

4 次查看(过去 30 天)
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

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 CenterFile Exchange 中查找有关 Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by