Delete rows in matrix based on elements of the column vector

Hi all,
I'm new to matlab and I need some help.
There is a matrix A = rand(10,4) and a column vector B = [0 0 1 1 2 2 3 3 4 4]'. I am trying to figure out how to clean A based on the values from B.
I would like to get rid of a row in A if there is 2 at the same position in B. In other words, if B(1) = 2 then A(1,:) = [ ]; and so on.
In my head it sounds like "if there is 2 in the column vector at the same position as this row in matrix then delete this row, do the same for the rest of rows". But this also will create a shift in matrix A, right? What function could perform this conditional cleaning on a huge matrix (5*10^6, 1000) based on corresponding column vector?
Thank you!

Plus de réponses (0)

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by