I want to remove the rows of matrix that the value of them in first column is zero…I use this code:
if true for i=1:7if m(i)==0m(i,:)=[];i=i-1;endendend
I run this code for this matrix but the answer is not true,it could not remove all rows that the first column of them is zero..
if true >> m=[1 2;3 4;0 5;3 0;0 4;0 54;3 22]
m =
1 2 3 4 0 5 3 0 0 4 0 54 3 22if true >> for i=1:7if m(i)==0m(i,:)=[];i=i-1;endendend
but when we saw the result,the result is: >> m
m =
1 2 3 4 3 0 0 54 3 22 end
is my cod wrong?
Best Answer