MATLAB: Delete rows in a matrix that contain ONLY a negative number

delete rowslarge matrixnegative numbers in a row

Hello
I've got a really large matrix (say 2000 x 3000) and I want to delete the rows that contain ONLY the negative number -999.
For example, I've got A = [5 3 -999 ; -999 -999 -999; 4 1 7 ; -999 -999 -999]
and I want my new matrix to be A = [5 3 -999 ; 4 1 7]
How can I do that?
Thanks!

Best Answer

idx = all(A == -999, 2);
A(idx, :) = [];