Reputation: 49
In example matrix
a1=[1;1;1;2;2];
b1=[1;1;2;2;2];
Can I compare a1
and b1
matrix, which is equal in the case of 1 value in a1
matrix?
target matrix
c1=[1,1,0,0,0];
Upvotes: 1
Views: 37
Reputation: 65430
You can create a logical array by using the ==
operator. Based on your question, I assume you want where a1
and b1
are both equal to 1. We can use the and (&
) operator to combine the two logical arrays created by a1 == 1
and b1 == 1
.
c1 = a1 == 1 & b1 == 1;
% 1 1 0 0 0
Upvotes: 1