Search code examples
matlabmatrixmatrix-indexing

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?


Solution

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