MATLAB: Raise the zeros in the vector up

vectors

If I have a vector [5 8 0 7 9 0 3], how do I put it this way: [0 0 5 8 7 9 3] use only function if-else
thank you.

Best Answer

Something like this,
v = [5 8 0 7 9 0 3]
ind = v==0;
v = [v(ind) v(~ind)]