MATLAB: Numbering rows and then using these numbers for another vector of equal n dimensions

ind2subreplacing numbers with zerorows

If I have a matrix for example
A = [ 1 2 3; 1 2 5; 0 55 8; 0 0 0; 7 8 9; 4 0 5; 0 0 0] and I have a vector
B = [ 1; 2; 3; 4; 5; 6; 7].
(please note these are small for simplicity but my actual matrices and vectors are much bigger)
Now say I wanted to record the row numbers at which all three columns contained zeros and then replace the numbers in B at these particular rows with zero also so I would be left with
B = [1; 2; 3; 0; 5; 6; 0]
How would I do that. I think I need to use the ind2sub function but I cant get my head around how to do this
many thanks in advance šŸ™‚

Best Answer

B( ~any(A,2) ) = 0;