Skip to main content
2 of 3
improved formatting
Kuba
  • 138.9k
  • 13
  • 297
  • 803

Extracting matrix rows when one of its elements is part of a list (without a loop)

I have a matrix whose rows I want to extract based on whether the elements of one of its columns is a member of another vector (calling it the "comparison vector").

I would like to get better at using functional programming, and so I want to avoid using a loop, if it´s possible. I believe I have the right functions: Select and MemberQ. But I can´t coerce MemberQ to compare the element of the matrix to each element of the comparison vector.

If there´s a duplicate answer, I´m willing to be lead to it (I´ve searched though)...

Verde
  • 85
  • 5