# Output Length of singal filtered using FIR Filters

1. ## Output Length of singal filtered using FIR Filters

Hello Experts,

The output of the FIR filters is convolution of the input signal and the filter kernel. In that case, the length of the output signal should be greater than input signal by M-1 points where M is the length of the filter kernel.

x=ecg(500)'+0.25*randn(500,1); %noisy waveform
h=fdesign.lowpass('Fp,Fst,Ap,Ast',0.15,0.2,1,60);
d=design(h,'equiripple'); %Lowpass FIR filter
y=filtfilt(d.Numerator,1,x); %zero-phase filtering
y1=filter(d.Numerator,1,x); %conventional filtering

In the above code, the length of the output is same as the length of my input signal even though I have implemented FIR filtering.

Can someone explain the reason of same length of the output signal? I expected my output signal to be greater than input signal.

Does MATLAB use convolution for filtering?

•

2. ## Re: Output Length of singal filtered using FIR Filters

help filter
I expect if you read the docs, you'll find some option to get the extra samples at the end (for the FIR case). likewise there's probably an option to provide initial conditions for IIR filters.

1 members found this post helpful.

•

3. ## Re: Output Length of singal filtered using FIR Filters

Originally Posted by permute
help filter
I expect if you read the docs, you'll find some option to get the extra samples at the end (for the FIR case). likewise there's probably an option to provide initial conditions for IIR filters.
Thank you for your reply permute. I saw the help for both filtfilt and filter. None of them share any information with respect to FIR filters (Although, they show the example I posted before). Also, I am trying to understand the conceptual difference between those written in DSP texts and those obtained from Matlab and other software packages.

For IIR, I believe there is no convolution taking place. Its combination of multiplications and additions between co-efficients, past outputs, past and present inputs to calculate present output. Hence, the same length of the output is expected.

For FIR, since the operation is convolution, I am expecting a longer output. But, I am sure MATLAB is correct. Hence, I need to know my mistake conceptually.

•

4. ## Re: Output Length of singal filtered using FIR Filters

both FIR and IIR perform the convolution operation. IIR filters have an impulse response that is infinitely long. The filter operation probably just returns the output as the same length as the output to be consistent in both the IIR and FIR cases.

you can also do things like append zeros to the end of the data, or append the first samples. Then you can see the expected response for convolution or cyclic convolution.

1 members found this post helpful.

--[[ ]]--