MATLAB: How to delete that row from the matrix which the summation of elements more than 5

for loopmatrixrow

I have matrix :
C =[
1 0 0 0 0 6
1 0 0 0 5 6
1 0 0 4 0 6
1 0 0 4 5 6
1 0 3 0 0 6
1 0 3 0 5 6
1 0 3 4 0 6
1 0 3 4 5 6
1 2 0 0 0 6
1 2 0 0 5 6
1 2 0 4 0 6
1 2 0 4 5 6
1 2 3 0 0 6
1 2 3 0 5 6
1 2 3 4 0 6
1 2 3 4 5 6];
I need to remove that row, where the number of elements more than 5.
For example the last row of matrix c has 6 elements, so the code should remove the last row from matrix C.
I could write the code, but it is just for one row.
I need to make it suitable for all rows. I have tried, but I couldn't.
Could anyone help me?
My code:
C =[
1 0 0 0 0 6
1 0 0 0 5 6
1 0 0 4 0 6
1 0 0 4 5 6
1 0 3 0 0 6
1 0 3 0 5 6
1 0 3 4 0 6
1 0 3 4 5 6
1 2 0 0 0 6
1 2 0 0 5 6
1 2 0 4 0 6
1 2 0 4 5 6
1 2 3 0 0 6
1 2 3 0 5 6
1 2 3 4 0 6
1 2 3 4 5 6];
C~=0,2;
E=size(C,2);
if sum(C(16,1:E))>5 %<-------this just checking row-16
C(16,:)=[];<---------------and removing row 16
end
Here, in my code I wrote the number of single row manually, but actually right code should find automatically all rows.

Best Answer

removeIdx = sum(C>0,2)>5;
C(removeIdx,:) = [];