MATLAB: If you have an input argument v that is a row-vector and another input a, that is a scalar. How do you have a function that moves every element of v that is equal to a to the end of the vector

loopsrow vector

For example,
x= move ([1 2 3 4], 2), i want x to equal to [1 3 4 2]
thanks an advance

Best Answer

Even more generic
a=[1 2 3 4 3 2 1]
idx=a==2
b=[a(~idx),a(idx)]