Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
2 of 2 Described what I was reading with the accelerometer; ToDiscreteTimeModel for sampled data question.

Butterworth single pole, 5 Hz cut-off frequency on accelerometer data for single axis

I have read other posts here on using the Butterworth filter in Mathematica, however, I am having a hard time understanding the chain of functions and their parameters as applied to my case, and I am not confident with what I am seeing.

I sampled the 3 axes of my accelerometer at 128 Hz in the field, and can successfully import, view and plot the CSV file in Mathematica.

I select only the column of data I am interested in, the 5th column, the Z-axis (colinear with gravity), and plot it. So far so good.

data2 = Query[All, {5}] @data

However, when I go to chain the two functions, RecurrenceFilter and ToDiscreteTimeModel, with the ButterworthFilterModel (assigned to LPF) as an argument to ToDiscreteTimeModel like so:

LPF = ButterworthFilterModel [{"Lowpass", 1, 5}]

filtered = RecurrenceFilter[ToDiscreteTimeModel [LPF, 1], data2]

I can see the adjusted outputted list, which appears in the same form as the input list with the newly calculated values, however, the plot doesn't seem right:

Final plot of filtered Z-axis data

I am not sure of the syntax of the chained functions, nor the choice of 1 as the period argument given to the function ToDiscreteTimeModel, since I think that should be 0.0078125 (1/128), but neither seem to plot the way I would expect with either 1 or 0.0078125 (1/128) in there.

I would have expected a smoothed curve of the raw data before applying the filter as shown here (column 2 is just the integer index of the sample. I used just column 5 when doing the last step):

Plot of raw data - column 2 and column 5

Edit: I should mention that this is with the accelerometer on a large rotating turntable at the periphery, and I was attempting to find any impulses in the Z-axis as it spun around. If you have sampled date, why do you need to 'sample' it again using ToDiscreteTimeModel, if I am correct in this assumption?

Any feedback on whether this is simply a plotting, syntax, or function use issue would be much appreciated. Thank you.