function newx = shuffle(x)
            temp = x(end);
            x(end) = [];
            newx = [temp x];

What are the values of x?
x = shuffle([5 4 3 2 1]);