MATLAB: Subtract row from previous row

row

I have a column of data (n long) and I want to subtract each row from the previous. So x = 1 2 6 1 etc
and I want to subtract row 2 from row 1, then row 3 from row 2 … etc. Ans = -1 -4 5 etc.

Best Answer

x(1:end-1)-x(2:end)