Derivation

Mayou's icon

Hello,

I would like to know what is the more efficient way to get the derivation of a continuous stream of data (real time) :

Max Patch
Copy patch and select New From Clipboard in Max.

I am using (f(X+h)-f(x))/h as it can be seen here :

Another idea ?

Thanks

Mathieu

justin's icon

do u mean deviation: http://en.wikipedia.org/wiki/Absolute_deviation
i get the feeling "derivation" is faux-amis?

also AFAIK u cant put formulas as arguments for maths objets (as is the case with the divide), u need to use expr for that.

Mayou's icon

Oops sorry I mean "to differentiate" :

f'(x)= (f(x+h)-f(x))/h or (f(x[i+1])-f(x[i-1)])/(x[i+1]-x[i-1])

justin's icon

well here is an attempt at translating the equation to expr, but it's broken...
i suspect my algebra is not up to scratch or the equation isnt right. either way the process should at least demonstrate how to translate equations into expr.

i didnt try the second equation... also it may be useful to explain the context of the equations, as this might make it easier for others to help.

hope that's vaguely useful, sorry dont have much time to look into this.

Max Patch
Copy patch and select New From Clipboard in Max.

j

Mayou's icon

Thanks justin,

I finally found a way to solve the problem :

Max Patch
Copy patch and select New From Clipboard in Max.

Here is my solution :

(With a low pass filter at the end to smooth the values)

Maybe there is a better way

Mathieu

justin's icon
Max Patch
Copy patch and select New From Clipboard in Max.

think [bucket 2 1] might be better, cos it outputs current value and previous value. otherwise it outputs previous and one before previous (ignores current value)... look at float number boxes and it should explain better!

Mayou's icon

Thanks I was just thinking about that problem ! =)

Now my input data and differential data are sync.

justin's icon

de rien ;)