MATLAB: Calculate difference between successive vector values.

mathematicsMATLABvector

Hi all, Hopefully a straightforward question, but one that I'm struggling with. I have a vector and want to create a new vector whose values are equal to the difference between successive values from the previous vector. e.g A = [1,2,3,3,0] want B = [1,1,0,-3]
What is the simplest way of doing this? Many thanks in advance. Will

Best Answer

A=[1,2,3,3,0]
B=diff(A)