Q:

Create two vectors that are shifted to the right of a given vector but filling in the left entries with zeroes

I have a vector x = [1 2 4 2 -1 3] and I need a vector y = [0 1 2 4 2 -1] and a vector z = [0 0 1 2 4 2] so it is the same length as x but in y, the elements are shifted by one and in z the elements are shifted by two and so forth with other vectors.
I tried with:
x = [1 2 4 2 -1 3];         
y = [0, repmat(x,1)]

The problem is that in this way i have a vector with length length(x)+1 and I don't want the last element. I tried with:
y = [0,repmat(x,1)- x(length(x))]     

and with this I have solved the problem of the last element but I don't want to get a 0. I just want my vector of the same length of x.

A:

x = [1 2 4 2 -1 3];         
y = [0, x];
y = y(1:end-1);
z = [0, y];
z = z(1:end-1);

Use the end statement to select the last element in a vector, and then move one back from there, shortening your array by one. Also, your call to repmat is redundant, as you van just call the vector itself.

A:

A trick that I have if you don't want to mess around with indexing is to use filter with the [0 1] kernel.  The leading 0 in the kernel is important because it ensures that the first coefficient is zero in the output followed by simply delay copying all of the elements one element to the right.  An added bonus to filter is that it ensures that the output is the same length as the input.
You can use this output and apply filter again on the intermediate result y, or use the kernel [0 0 1] on x again to achieve the last result z:
>> x = [1 2 4 2 -1 3];
>> y = filter([0 1], 1, x)

y =

     0     1     2     4     2    -1

>> z = filter([0 1], 1, y)

z =

     0     0     1     2     4     2

