# 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:

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):

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.

• There might be something wrong with the parameters of filter, but the more serious problem is, the structure of data2 is improper. Please modify definition of data2 to data2 =data[[All, 5]] and try again. (Don't forget the compare the difference between new and old data2. ) – xzczd Aug 16 '18 at 6:42
• Can you explain in words what you want to filter out and what do you want to display in Fig. – Alex Trounev Aug 16 '18 at 8:15
• data2 is the selection of the 5th column of data (the acceleration in z-axis). The other columns are timestamp, tick (integer index), x-axis, y-axis. The way I have it Mathematica is returning the 5th column. I am trying to apply a single-pole Butterworth low-pass filter with a 5 Hz cut-off frequency. The sensor was sampling at 128 Hz. – Eggy Aug 16 '18 at 19:23
• Alex, I am following a specification that requires that the sensor data I sampled at 128 Hz is then: "The acquired test data shall be post-processed, with a 4-pole, single pass, Butterworth low pass ﬁlter using a corner frequency (Fn) of 5 Hz.". My guess is that it is to smooth out the data, and not register impulses of less than 1/5 s? – Eggy Aug 16 '18 at 19:29