MATLAB: How could I add a zero before the last element in any size vector

vector

For example, if I was given vec[-5 4 -4 6 8 -3], how could it become vec[-5 4 -4 6 8 0 -3]? In addition, the code could work for any size vector.

Best Answer

v = [-5 4 -4 6 8 -3] ;
iwant = [v(1:end-1) 0 v(end)];