I have generated some real data of the motion of a damping pendulum:
I took its derivative in R by taking the difference of consecutive points and dividing by difference in time. There are 1202 data points in this picture.
That gave this graph:
I took the derivative of this graph again:
However, this graph is very erratic and unusable for analysis. I was wondering if there is a function in R which allows for accurate numerical differentiation? I know of Fourier Transforms although I'm not sure how to directly apply them on a damping pendulum.
This is a function I'm using in R to compute the derivative:
derivative <- function(x,y,deriv0){
# deriv0 = value of the derivative at time zero
deriv <- diff(y[2:length(x)]) / diff(x[2:length(y)])
w = length(x)-2
deriv <- c(deriv0,deriv[1:w])
time <- x[1:length(x)-1]
return(data.frame(time,deriv))
}
The original dataset is here:
Thanks