i want to remove the rows which contain all zeros. so finally i expect a matrix containing with the remaining rows. I use a 'for loop' to represent each row, but then i get a error "Index of element to remove exceeds matrix dimensions". help me to get rid of these zero elemental rows. thank you. example: a =[0 0 0 0
1 2 3 4 2 0 1 1 0 0 0 0]
new_a =a;
for i=1:4
if a(i,:)==0 new_a(i,:)=[]; end end new_a
Best Answer