Digital signal derivative I'm new to signal processing and I need your help: I have an array of 128 elements (call it Window) filled with 128 samples taken from a sensor. I was wondering how to find the derivative of this digital signal. I found this formula on wikipedia:

m = F[n] - F[n-1]


where, for me, F[n] is Window[n]. I'd like to obtain an array M filled with all the derivatives. But there's something I miss: The first step would be:

M[0] = Window[0] - Window[-1]


and I haven't Window[-1]. How can I manage this issue? Thank you in advance. 

https://en.wikibooks.org/wiki/Digital_Signal_Processing/Discrete_Operations#Derivatives
In theory, M[0] doesn't exist. Your discrete derivative is only defined on [1,127].

As a practical solution, you can define M[0] as a null element of your signal. For example if you expect values between -1 and 1, take M[0] = 0.

In the case of real-time, there is two options:


Either you save the last value of your buffer so you can take M[0] = last for the next ones, and initialize last as 0, or whatever seems coherent with your expected signal;
Either you start computing the derivative at M[1] and your processing will have a latency of 1 sample.