If I have 2 vectors: A with n elements and B with m elements and m < n,
how do I identify all the elements in A which are in B, without using a for loop?
Many thanks
C = intersect(A,B) will give you all the elements which are in both.
There's also ismember(A,B), which will return a logical array indicating for each member of A whether it is also a member of B.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With