MATLAB: Subtracting 2 cells in an array

arrayMATLAB

Given:
A=[1,3,5,2,6,1];
Is there a function where I can get a difference of first and following cell in above matrix?
For example, output should be = 1-3, 3-5, 5-2,2-6,6-1 = -2,-2,3,-4,5
Finally, is there a way to sum the entire value in the matrix?
Thanks

Best Answer

>> -diff(A)
ans =
-2 -2 3 -4 5
>> sum(-diff(A))
ans =
0