# How can I calculate how much of my signal at the beginning and end will be affected by the filtering process?

I'm using a Butterworth bandpass filter to process my signal (low-pass + high-pass, I am also applying a notch filter). I would like to calculate how much of my signal at the edges will be affected by this filter, so I can record additional data and later trim the edges and not have the filter artifact in my signal of interest (or eventually use padding). How can I calculate the duration of the affected signal at the start and end?

Thank you!

• Technically, the Butterworth filter's impulse response is infinitely long, so everything affects everything after, forever. Why not use an FIR (finite impulse response) filter? (You might be, assuming this is a digital filter, and you chose to approximate the original Butterworth design with an FIR; but that would be something a bit unusual, and you'd probably have mentioned it.) Commented Apr 17 at 10:04
• As Marcus mentioned, the Butterworth filter will affect everything forever. What you probably mean is: looking at the filter's step response, after which amount of time does it's amplitude stay within $1\pm\epsilon$ with $\epsilon$ being your desired maximum deviation.
– Max
Commented Apr 17 at 10:17
• Have a look at Transient_Response_Steady_State, there you can find the description for the transient response (or settling time) in the case of FIR and IIR filter. However, as it has already been said, IIR filters are a little bit more complicated. For IIR filters also check IIR filter relaxation time computation Commented Apr 17 at 11:57
• Thanks everyone for your answers and thanks, @Irreducible, for this material that I found really useful! I will try to build a FIR filter and compare their effects on the signal. Commented Apr 19 at 8:24

Evaluate the unit-sample response of your filter (by sending in [1,0,0,0,...]). The result will be the residual effect of every sample on every later sample. You can evaluate that and how many samples until the result decays to a value you consider insignificant. The unit-sample response is the "impulse response" for digital filters. For FIR filters (Finite Impulse Response), the result will be the coefficients of the filter and shows how the start that is effected (the initial filter transient) can't be longer than the filter. For IIR filters (Infinite Impulse Response), the result theoretically goes on for infinity, but for typical filter structures will decay and with that we can choose our level of significance. Also we should see from this that there is no "edge effect" at the end of the result for a filtered waveform for either causal FIR or IIR filters, only the beginning.

For example you could do:

[b,a]=butter(2,[.15,.3]);

figure(1);
freqz(b,a);

figure(2);
impulse_response = filter(b,a,[1,zeros(1,100)]);
impulse_response = impulse_response/(max(abs(impulse_response)))

plot(20*log10(abs(impulse_response)))
xlabel('Time Index')
ylabel('Magnitude in dB')



which produces a bandpass Butterworth filter of order 5

and decays as follows:

• @PeterK. thanks for the nice addition! Commented Apr 17 at 14:19
• I see now. Thank you so much for your clear comments and material. I found them really helpful! Commented Apr 19 at 8:21