Reputation: 1838
Say I have
a=[1 2 3 4; 5 6 7 8];
If I then have x=3, y=7, how can I check that (3,7) exists in array a
but also ensure that if I check for the pair x=3, y=8 (3,8), then it returns false and NOT true?
EDIT: (3,7) should return true but (3,8) false because 3 and 7 are in the same column, but 3 and 8 are not. Also (7,3) should be false because for (x,y)
, x
corresponds to element in 1st row and y
in 2nd row
EDIT2: I see isPresent = any(ismember(a.', [x y], 'rows'));
for the arrray a
.
But what if I have this: b=[1 5; 2 6; 3 7; 4 8]
. Then how can I ensure that (3,7) is true but (7,3) is false?
Upvotes: 0
Views: 957