MATLAB: How to find rows in a matrix that have elements in a certain column that satisfy certain condition and create a new matrix out of those rows

MATLABmatrix manipulation

I might not have phrased the question best, but I got a matrix that has 5 columns and thousands of rows, and now I want to find rows that have elements in 5th column that satisfy certain condition(equal to 0 or 2 or 10) and create new matrix with those exact rows?
Thanks in advance.

Best Answer

tf = ismember(YourMatrix(:,5), [0, 2, 10]);
NewMatrix = YourMatrix(tf, :);