MATLAB Answers

0

finding same values in the same place in different columns

Asked by Jos Huigen on 24 Jun 2019
Latest activity Answered by Vismay Raj on 24 Jun 2019
I have 2 columns, filled with scalars 0 or 1. I would like matlab to find all the 1's that are in the same place in one column as in the other, and the same thing for the 0's. How am I supposed to go about this? Any help would be greatly appreciated!

  1 Comment

So, you want to find all rows that are 11, and 00? If so, I suggest using intersect.

Sign in to comment.

1 Answer

Answer by Vismay Raj on 24 Jun 2019
 Accepted Answer

Not the right way but gets the job done, assuming the vectors are A and B
ANSWER = ((A+B) == 2) + ((A+B) == 0)
the brackets are really important , now in answer the 1s are corresponding to the indices where both A and B match

  0 Comments

Sign in to comment.