Your program starts by defining newM <- M<0>.
Then you create a loop that stacks the other columns on top for i :=1 to cols(M)-1.
But if you send a single column vector there is no column 1, "this array index is not valid "for a single vector column array.