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

Réponses (3)

Jos (10584)
Jos (10584) le 14 Oct 2013
p^q^r
p = true ; q = true ; r = false ;
tf = p && q && r
help and

1 commentaire

Mohamad
Mohamad le 14 Oct 2013
Well no cause I am looking to have a truth table of 1 and 0.

Connectez-vous pour commenter.

[P, Q, R] = ndgrid([0 1]);
truthtable = P & Q & R;
[P(:), Q(:), R(:), truthtable(:)] %display it
Jan
Jan le 14 Oct 2013
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.

Question posée :

le 14 Oct 2013

Réponse apportée :

Jan
le 14 Oct 2013

Community Treasure Hunt

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

Start Hunting!

Translated by