MATLAB: How to decrease for loop variable counter when deleting rows in a matrix

arrayfor loopiterationMATLAB

I have an array A in which I delete rows based n a certain condition within another corresponding matrix which consists of the mean values of A. Each time I delete a row, I want my 'i' counter to jump back 1 iteration in order to not skip rows.
Means_Array=mean(A,2);
for i = 1:size(A,1)
if Means_Array(i,1)==0
Means_Array(i,:)=[];
A(i,:)=[];
i=i-1
end
end
This does however not work for some reason and the 'i' resets back to the value it would have taken if the i=i-1 was not even there.

Best Answer

Just specify the for loop values to count downwards:
for i = size(A,1):-1:1
...
end