Filters performance analysis

236 views Asked by At

I am working on some experimental data which, at some point, need to be time-integrated and then high-pass filtered (to remove low frequency disturbancies introduced by integration and unwanted DC component).

The aim of my work is not related to filtering, but still I would like to analyze more in detail the filters I am using to give some justification (for example to motivate why I chosed to use a 4th order filter instead of a higher/lower one).

This is the filter I am using:

delta_t = 1.53846e-04;
Fs = 1/delta_t;
cut_F = 8; 
Wn = cut_F/(Fs/2);
ftype = 'high';
[b,a] = butter(4,Wn,ftype);
filtered_signal = filtfilt(b,a,signal);

I already had a look here: High-pass filtering in MATLAB to learn something about filters (I never had a course on signal processing) and I used

fvtool(b,a)

to see the impulse response, step response ecc. of the filter I have used.

The problem is that I do not know how to "read" these plots.

What do I have to look for?

How can I understand if a filter is good or not? (I do not have any specification about filter performances, I just know that the lowest frequency I can admit is 5 Hz)

What features of different filters are useful to be compared to motivate the choice?

1

There are 1 answers

1
GameOfThrows On

I see you are starting your Uni DSP class on filters :) First thing you need to remember is that Matlab can only simulate using finite values, so the results you see are technically all discrete. There are 4 things that will influence your filtering results(or tell you if your filter is good or bad) which you will learn about/have to consider while designing a Finite response filter:

1, the Type of the filter (i.e. Hamming, Butterworth (the one you are using), Blackman, Hanning .etc) 2, the number of filter Coefficients (which determines your filter resolution) 3, the sampling frequency of the original signal (ideally, if you have infinite sampling frequency, you can have perfect filters; not possible in Matlab due to reason above, but you can simulate its effect by setting it really high) 4, the cut-off frequency

You can play around with the 4 parameters so that your filter does what you want it to.

So here comes the theory: There is a trade-off in terms of the width of your main lobe vs the spectrum leakage of your filter. The idea is that you have some signal with some frequencies, you want to filter out the unwanted (i.e. your DC noise) and keep the ones you want, but what if your desired signal frequency is so low that it is very close to the DC noise. If you have a badly designed filter, you will not be able to filter out the DC component. In order to design a good filter, you will need to find the optimal number for your filter coefficients, type of filter, even cut-off frequency to make sure your filter works as you wanted.

Here is a low-pass filter that I wrote back in the days, you can play around with filters a lot by filtering different kinds of signals and plotting the response.

N = 21; %number of filter coefficients
fc = 4000;  %cut-off frequency
f_sampling = fs; %sampling freq
Fc = fc/f_sampling;
n = -(N-1)/2:(N-1)/2;
delta = [zeros(1,(N-1)/2) 1 zeros(1,(N-1)/2)];
h = delta - 2*Fc*sinc(2*n*Fc);
output = filter(h,1,yoursignal);

to plot the response, you want to plot your output in the frequency domain using DFT or FFT(in Matlab) and see how the signal has been distorted due to the leakage and etc.

NFFT=256;           % FFT length
output=1/N*abs(fft(output,NFFT)).^2;      % PSD estimate using FFT

this gives you what is known as a periodigram, when you plot, you might want to do the 10*log10 to it, so it looks nicer

Hope you do well in class.