Closed RanCao2018 closed 5 years ago
Numerical differentiation can be implemented as linear convolution. In Matlab for instance, diff(X) is basically the same as conv(X,[1,-1]). If you know the sample interval dt, it would be diff(X)/dt and conv(X,[1,-1]/dt)
diffnc (as originally implemented by Stefan Schaal in Matlab, see the comments) works the same, but also smooths the signal by taking both neighbouring samples into account, i.e. conv(X,[1,0,-1]/2*dt)
diffnc is essentially a "minimal" version of this https://en.wikipedia.org/wiki/Savitzky%E2%80%93Golay_filter with m=3 and k=1.
In Python it would perhaps be more sensible to use numpy.gradient. But I copied diffnc from previous Matlab code I was using to ensure the result would be the same.
I got it. Thank you
Hello, anyone can help to explain the principle of the function "diffnc" in /python/dmp/Trajectory.py? I guess that it is used to calculate the difference derivative, but I cannot understand how it works. Do there have any related expansion or link? Thank you😀