[SciPy-user] probably a stupid question: MatLab equivalent of "diff" ?
lev at columbia.edu
Fri Dec 29 09:41:33 CST 2006
Received from Otto Tronarp on Fri, Dec 29, 2006 at 11:26:06AM EST:
> 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 :import numpy
> In :numpy.diff([1,2,4,1])
> Out:array([ 1, 2, -3])
Moreover, if you want to ignore the rising edges, you can use
something like this:
a = <array of some integers>
da = diff(a)
More information about the SciPy-user