I have a signal $x[n]$ and I filter the signal using an FIR bandpass filter to receive $y[n]$. (implementation in MATLAB using built-in function firpm). The filtered signal $y[n]$ is compensated for its delay of half the filter order.

The problem is that the filtered signal $y[n]$ has a major peak at the beginning that does not exist in the original signal.

  • What is the cause of that peak?
  • Is it possible to attenuate the peak?

The peak (or response) is shown in the second plot of the filtered signal between 0-0.5 seconds (Note that I only show the first few seconds of a several minute signal) The peak (or response) is shown in the second plot of the filtered signal between 0-0.5 seconds (Note that I only show the first few seconds of a several minute signal)

The signal is sampled at 250 samples/sec. The desired filter passes frequencies between 10-20 Hz. The code for the implementation of the filter:

fs=250; % sampling rate; 
n= 120; % filter order;
freqs = [0 5 10 20 25 fs/2]/(fs/2); % normalized frequencies in Hz;
amps = [0 0 1 1 0 0 ]; % amplitudes;
b = firpm (n,freqs,amps); % define filter coefficients; 
filtered_signal = filter (b,1,original_signal); % apply FIR filter;
  • 2
    $\begingroup$ Can you add your code, or your in- and output signals, as well as a plot of what you're observing? $\endgroup$ Commented Aug 13, 2017 at 10:16
  • $\begingroup$ It's really difficult to answer that question without any further details. I could imagine that this is due to initial conditions of the filter. I did mention this in one of the answers (see the comment) $\endgroup$
    – jojeck
    Commented Aug 21, 2017 at 14:48
  • $\begingroup$ Further details were added to the original question $\endgroup$
    – D.Cohen
    Commented Aug 22, 2017 at 6:48

1 Answer 1


It's the initial transient at the filter output due to the implied zeros of the input signal for $n$ less than $0$.

Let me simulate the effect here, since you do not post the actual data I will model it as close as necessary, with the following Matlab/Octave code:

Fs = 250;                    % Sampling frequency in Hz.
Ts=1/Fs;                     % Sampling period in seconds.
t = [0:Ts:4];                % Simulation interval for the signals.
L = length(t);               % Simulation signal lengths in samples.

x = 8E4 + 1E4*exp(-t)  + 1E3*filter(fir1(43,0.03),1,randn(1,L));
% Note: x[n] is roughly modeling your input signal sampled at 250 Hz.
% I have not included those spikes, as they're irrelevant for this analysis

b = fir1(65,[10/125 20/125],'bandpass');   % a BPF with passband [10,20] Hz.
y = filter(b,1,x);           % Obtain the filtered output signal.

% Now, observe the outputs...
plot(t,x);title('Input signal x[n] of duration 4 seconds')
plot(t,y);title('Output signal y[n] obtained from BPFing of the input');

As it can be seen below:
enter image description here

So the peak at the beginnig of the output is clearly observed.

It's intuitive to look at the bandpass filter's impulse response : enter image description here

Looking at the BPF impulse response (especially the second subplot) reveals the fact that the transient is inline with the impulse response; their durations are the same and their shapes are very similar.

In fact, looking at the transient's duration (which is about 0.25 seconds) it matches with the number of samples the impulse response has: $ N \times T_s = 0.25 s \rightarrow N = 0.25 \times 250 = 62.5 \text{ samples}$ This coincides with the BPF impulse response which was designed as a $65^{th}$ order filter having $66$ coeffcients.

So we have the clue that the peaking at the begining is indeed the impulse response (a transformed version of it) at the output.

The reason of this can be understood by looking at the convolution sum: $$y[n] = \sum_{k=0}^{L-1} x[k]h[n-k] $$ which shall be evaluated for $n \geq 0$

now in the sum it can be seen that signal values for $k < 0$ are implied to be zero. Lets show this effect on the flip and drag graphical evaluation below: enter image description here

Now first obervse that in its initial part, the signal $x[n]$ has an almost constant value. Then it can also be seen that until $n=65$ the overlap between the signal and impulse response is partial and therefore there won't be enough cancellation from the positive and negative samples of the impulse response to produce (apprx) zero output. But when $n \geq 65$ there is full overlapp between the impulse response and the signal (which is almost constant) therefore in the summation the positive and negative samples of the impulse response will cancel each other yielding a small, (zero-dc), output which represents the expected output after $n > 65$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.