Signal processing question (phase response of a digital filter)
Show older comments
Suppose I have a digital filter with length(b)=8 and length(a)=6 (i.e. 7th order numerator and 5th order denominator).
If I look at freqz (or fvtool), before computing the frequency response, the denominator will be padded with two extra zeros at the end so that the two polynomials are the same length. The two extra poles at the origin won't change the magnitude response but it will change the phase response. Why is this the phase response (displayed by fvtool) the one we want vs. what we would get if we simply evaluated the ratio of the numerator and denominator polynomials (unpadded) around the unit circle?
For a FIR filter with 20 zeros, fvtool shows 20 poles added at the origin again affecting the frequency response. I suppose this is the same as my first question, but why are the 20 poles added and why is this the desired phase response to display?
Thanks for any insights you may have on this question.
~Paul
Answers (1)
Hi Paul,
Can you provide a simple concrete, example that illustrates your concern?
I suspect that you're seeing the difference between how the numerator and denominator are entered into freqz and how they are evaluated inside of freqz.
The b,a inputs to freqz are defined in ascending powers of z^-1. So, for a filter like
H(z) = (1 + 2*z^1 + 3*z^-2) / (1 + 5*z^-1)
we'd call freqz with
freqz([1 2 3],[1 5])
Inside of freqz, for an IIR filter, the numerator and denominator polynomials are evaluated as a function of frequency in one of two ways: using polyval or fft.
polyval evaluates polynomials in descending powers of z. So if we multiply the numerator and denominator of H(z) by z^2, we get
H(z) = (z^2 + 2*z + 3) /(z^2 + 5*z)
and the Matlab polynomial representation of the denominator requires padding with one zero: [1 5 0]. The zero padding is needed to get the correct result using polyval, and is not adding an extra pole (the poles of H(z) are at z = 0 and z = -5 regardless).
If using fft, padding the denominator with one zero doesn't affect its fft.
A 20th order FIR filter does have 20 repeated poles at the origin, which you'll see by converting the FIR filter H(z) written in terms of z^-1 to a rational function of z, from which the zero and poles of H(z) are defined. I don't think freqz does any zero padding of b in the FIR case because the numerator coefficients are the same when H(z) is written in terms of z^-1 or z, but it does have to account for the fact that the b is defined in ascending powers of z^-1 when computing the frequency response.
8 Comments
Paul Mennen
on 10 Aug 2023
It sounds like that there is no longer a concern with the actual computation of the frequency response in freqz. For transfer function H(z)
H(z) = (1 + 2*z^1 + 3*z^-2) / (1 + 5*z^-1) = (z^2 + 2*z + 3) /(z^2 + 5*z)
the frequency response is
H(w) = H(z = exp(1j*w))
which can be computed by substituting exp(1j*w) for z in either expression on right hand side. freqz does it using the second expression, but for sure you can get the same answer (mathematically) using the first expression. I don't know why freqz does it they way it does, but I wouldn't be surprised if it's been done that way going back to the very first release of the Signal Processing Toolbox. Just a guess.
The remaining question then regards the definition of the zeros and poles of H(z). I did some searching, and sure enough I found one reputable source that says "It is customary" to not consider the poles at the origin "when discussing the number of poles" a filter has, but it goes on to be very clear that those non-discussed number of poles at the origin do affect the phase response.
Having said that, my recollection is that its more typical to say that z0 is a finite pole of H(z) if H(z0) is not defined, and z0 is a finite zero of H(z) if H(z0) = 0. Also, H(z) can have poles or zeros (not both) at infinity depending on the orders of the numerator and denominator polynomials in z. Clearly H(z) above is not defined at z = 0, hence z0 = 0 is pole of H(z).
Or consider the one-samples delay, which seemed to be not considered by my reputable source
H(z) = z^-1 = 1/z
What are the poles and zeros of H(z)? I would say H(z) has a pole at z = 0 and does not have any finite zeros (it has one zero at z = inf), which follows from writing H(z) as a rational function in z and then looking at the roots of the resulting numerator and denominator, as I did in the example in my original answer.
In a practical sense, Matlab uses the definitions of poles and zeros as I've described and as you've seen, at least in the Control Systems and Signal Processing Toolboxes.
Paul Mennen
on 11 Aug 2023
Paul
on 12 Aug 2023
I'm afraid I disagree with the concept of "extra" poles (or extra zeros).
One has to define what a pole (or zero) is and then apply that definition to the transfer function H(z) in question.
The poles (and zeros) are not determined by the computational technique; rather the poles (and zeros) are an inherent property of the transfer function H(z), regardless of whether H(z) is written as a rational function in z or inv(z).
As you've seen, the pole(s) (and zero(s)) at the origin, as I've defined them, do have an impact on the frequency response, which is also an inherent property of H(z). If computing the frequency response via polynomial evaluation (whether in terms of exp(1j*w) as in freqz or in terms of exp(-1j*w) in your method), we don't need explicit knowledge of the pole and zero locations. But suppose we want to evaluate H(exp(1j*w)) based on just knowing the values (and multiplicity) of the poles and zeros and taking products of factors of the numerator and denominator. In this case, one must know about the poles (zeros) at the origin.
Another example is the inverse z-transform integral, which can be evaluated via the residue theorem, which in turn requires knowledge of the finite poles of H(z) as I've defined them, i.e., roots of the denominator when H(z) is written as a rational function of z.
If you have any references (preferably online) that discuss this idea of "extra" poles (or zeros), I'd love to read them to learn about other perspectives.
Paul Mennen
on 12 Aug 2023
Paul
on 12 Aug 2023
I think you meant that H(z) = 1 + 5z^-1 + 6*z^-2.
Yes, I would say that filter has two poles at the origin, for the exact reason you state: H(z=0) = inf (in a mathematically loose sense). The answers on this stackexchange post may be of interest, as might be this Wikipedia link. IMO, it is useful becasue it's always useful to know the inherent properties of the filter.
Let me again ask the question I asked above:
What are the poles and zeros of the unit delay D(z) = z^-1 ?
Here's a new question: Suppose we have a non-causal FIR filter Q(z) = z^2 + 5*z + 6. Do Q(z) and H(z) have the same zeros, and neither have any poles?
If so, would that imply that Q(z) and H(z) have the same responses (frequency, impulse, etc.), which they clearly don't? What other inherent property would be used to distinguish Q(z) from H(z)?
Paul Mennen
on 12 Aug 2023
Paul
on 12 Aug 2023
Whatever I was thinking when I rewrote H(z) was clearly incorrect. Was probably thinking about poles at -2 and -3.
For the FIR case, I think the poles and zeros are sufficient to determine impulse response, to within a gain, be it causal or noncausal. But for the IIR case, we’d need to know the region of convergence of H(z) to determine causality.
I’ll be sure to steer clear of the geology and economics crowds :)
Thanks for the discussion.
Categories
Find more on Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!