Shift a signal by a given number of samples
No, this is not shifting but windowing by a rectangular window. Shifting will not change the values of the samples, it will just change the relation between the sample values and the corresponding time indices.

In Matlab a (finite length, discrete-time) signal is simply represented by a vector of numbers. There is no relation to time indices. The interpretation which sample value corresponds to the index $n=0$ is up to you. So shifting a signal without any further processing in Matlab (or any other software) is meaningless.

If it's just about plotting, you can use stem(n,x) where x is your signal vector, and n is the corresponding vector of time indices. Shifting just involves specifying a different vector n, the data in x remain of course unchanged.

Shifting becomes important if it is part of some processing involving more than one signal, e.g. the computation of the deterministic auto-correlation or cross-correlation. In such a case you simply have to implement the corresponding formula.

EDIT:

If you have two signal vectors x and y which have the same number of elements N, and you want to add a shifted (e.g., delayed) version of y to the signal x then you can do two things. If y is shifted by M samples, you could define the sum by

z = [x(:),zeros(M,1)]+[zeros(M,1),y];

In this case the indices where only one of the two signals in non-zero (due to the shifting operation) are also taken into account. This may or may not be useful. If you want to disregard these regions and only take into account indices where both signals overlap, you can do this:

z = x[M+1:N]+y[1:N-M];

This is simply the middle region of the other sum vector z defined above.