[SciPy-user] probably a stupid question: MatLab equivalent of "diff" ?

Otto Tronarp otto at tronarp.se
Fri Dec 29 10:26:06 CST 2006

Quoting Stef Mientki <s.mientki at ru.nl>:

> Does anyone know the equivalent of the MatLab "diff" function.
> The "diff" functions calculates the difference between 2 succeeding
> elements of an array.

Then it is the numpy.diff function you'r looking for.

In [19]:import numpy
In [20]:numpy.diff([1,2,4,1])
Out[20]:array([ 1,  2, -3])


More information about the SciPy-user mailing list