3

I want to find common values in two arrays(For example if A=[1 2 3 4 5 6] and B=[9 8 7 6 3 1 2] the result is ans=[1 2 3 6]).Is there any method without using loop?

Thanks

Fatime
  • 197
  • 1
  • 5
  • 15

1 Answers1

8

use intersect(A,B) to get the answer.

Another option is to use ismember, for example A(ismember(A,B)).

bla
  • 25,846
  • 10
  • 70
  • 101