MATLAB: How to shift the vector element inside of the vector

shiftvector

Is there any fast way I can shift a vector, for example given:
a = [1 2 3 4 5]
How can I shift of two positions the vector in such a way that I get:
a = [0 0 1 2 3]
Thanks.

Best Answer

Another option:
a = [1 2 3 4 5];
as = zeros(size(a));
as(end-2:end) = a(1:3)
as =
0 0 1 2 3