MATLAB: Remove lines from logical matrix if values in 3 or more rows are equal to 1.

logicalsmatrix

If I have the matrix which has logical values
a = [0 0 0 0 0; 0 1 1 0 0; 1 1 0 1 1];
Then I would like to remove the last line as three or more values are 1 in them.

Best Answer

a = [0 0 0 0 0; 0 1 1 0 0; 1 1 0 1 1];
a(sum(a,2)>=3,:)=[]