1
$\begingroup$

Discrete Time Signal Processing by Oppenheim says that for the product of two DFTs (i.e. circular convolution) to be equal to linear convolution, the DFTs must be at least P + L - 1 long where P and L are the lengths of the time domain sequences used to compute the DFTs. I understand this to mean that the output of a digital filter will be longer than the input.

Matlab's filter function returns a sequence of the same length of the input. How does it do that? How is it avoiding aliasing in the time domain which you are supposed to get if you don't increase the length of the output?

It is desirable to have the filter output be the same length as the input. I can have the input and output be an integer number of cycles of a sinusoid and avoid any spectral leakage. Requiring that the signal be zero-padded for filtering makes avoiding spectral leakage impossible.

$\endgroup$
3
  • $\begingroup$ The output that is not presented for you is saved in the final state of the filter, use [y, zf] = filter(b, a, x); $\endgroup$
    – ZR Han
    Oct 29, 2021 at 1:47
  • $\begingroup$ @ZRHan: that's not true. The state is just the values in the delays of the filter, not the entire output, which in most cases is infinite anyway. $\endgroup$
    – Hilmar
    Oct 29, 2021 at 8:06
  • $\begingroup$ @Hilmar yes I don’t mean that the values of the states are exactly the output samples, I mean the output is saved in some form in the filter states. $\endgroup$
    – ZR Han
    Oct 29, 2021 at 10:30

1 Answer 1

4
$\begingroup$

A full convolution is Lx + Lh - 1 samples long. This can be truncated to two meaningful subsets, as documented in conv().

filter() is generally an iir filter, and will have an infinite output. Thus it is truncated at input length. If you like, you can read final state and insert initial state by adding parameters to i/o.

Implementation of FIR and IIR filtering is most easily understood in the time domain, I think. It is just a loop of mults and adds working on a delayline.

$\endgroup$
1
  • $\begingroup$ I was thinking in the context of FIRs. If the output is truncated then the transfer function isn’t the one specified by the coefficients, right? $\endgroup$
    – DavidG25
    Oct 29, 2021 at 2:08

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.