Logical Vectors and &

28 views (last 30 days)
Mark Tenorio
Mark Tenorio on 11 Mar 2018
Commented: Mark Tenorio on 11 Mar 2018
I have two logical vectors:
A = [0 1 1 1 1 0 0] B = [0 0 0 0 0 0 0]
C = A & B % C = [0 0 0 0 0 0 0]
Can someone explain to me why C = [0 0 0 0 0 0 0].

Accepted Answer

John D'Errico
John D'Errico on 11 Mar 2018
The & operator works on the elements of the two variables element-wise.
Since All elements of B are 0 (false) and it is true that if you and anything with false, then the result is uniformly false.
What else would you have expected?
  1 Comment
Mark Tenorio
Mark Tenorio on 11 Mar 2018
I don't know. That's why I hit the Ask button. But thank you for answering my question :)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!