I'm trying to apply a simple IIR Low Pass filter to clean up a set of data. I've designed the filter using MATLAB's designFilt function:
fs=25;
lpFilt = designfilt('lowpassiir','FilterOrder',32, ...
'PassbandFrequency',2,'PassbandRipple',0.2, ...
'SampleRate',fs);
fvtool(lpFilt)
output = filter(lpFilt, output);
S = seconds((0:numSamples-1)'/fs);
input_tTable = timetable(S, input);
output_tTable = timetable(S, output);
fvtool shows the following frequency response for the filter:
The filter is relatively flat on the pass band and clearly has a strong cutoff at 2Hz.
The input signal (shown below on the left) signal has a clear low frequency fundamental I'm trying to extract, and judging by sine waveform analysis (see markers below) has a frequency of approximately 0.25Hz. After applying the low pass filter (cutoff 2Hz), I would expect to see a clearer ~0.25Hz tone.
After using the filter to process the signal, the result is shown below (Left is input, right is output)
**I used the Signal Processing Toolbox Signal Analyzer to produce the figure
The resulting output signal (right) is quite different from what I expected. Firstly, in the time domain, the signal has a massive transient response with a large time delay. Also on the pass band, the frequency spectrum is somewhat different (Note how the input has a dip at 2Hz whereaws the output has a peak)
Can anyone explain to me why this is happening? Am I doing something wrong with my designing/using of the filter?
I appreciate any feedback