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

Tom Denniston tom.denniston at alum.dartmouth.org
Fri Dec 29 10:36:09 EST 2006


Ignore, mine.  Otto's answer is better.  I didn't see it.

On 12/29/06, Tom Denniston <tom.denniston at alum.dartmouth.org> wrote:
> I may be misunderstanding you but isn't what you want just:
>
> arr[1:]-arr[:-1]
>
> If you only want positive differences it's:
>
> (arr[1:]-arr[:-1]) > 0
>
> or negative:
>
> (arr[1:]-arr[:-1]) < 0
>
> These should be very fast.
>
> --Tom
>
>
> On 12/29/06, Stef Mientki <s.mientki at ru.nl> wrote:
> > Does anyone know the equivalent of the MatLab "diff" function.
> > The "diff" functions calculates the difference between 2 succeeding
> > elements of an array.
> > I need to detect (fast) the falling edge of a binary signal.
> >
> > There's derivate function in Python diff,
> > but when you use an binary (true/false) input,
> > it also detects rising edges.
> >
> > Probably a stupid question,
> > but I still have troubles,
> > digging to huge amount of information about Python.
> >
> > thanks,
> > Stef Mientki
> > _______________________________________________
> > SciPy-user mailing list
> > SciPy-user at scipy.org
> > http://projects.scipy.org/mailman/listinfo/scipy-user
> >
>



More information about the SciPy-User mailing list