Austin
Austin

Reputation: 7349

Remove rows in matrix where column equals any value in vector

I have a matrix A that is size 967874 x 3 and a vector v that is length 7211.

I want to create a new matrix B that equals matrix A minus all the rows in A where the 2nd column value equals any of the elements in v.

What's a fast way to accomplish this?

Upvotes: 0

Views: 64

Answers (1)

O'Neil
O'Neil

Reputation: 3849

B = A(~ismember(A(:,2), v), :)

Upvotes: 2

Related Questions