I have implemented an IIR low pass filter in direct form 2, the input to the filter is a unit impulse $\delta[n]$. I have calculated the output of the filter for the mentioned input using the difference equation of direct form 2, the equations are given below:

$$\begin{align}w[n] &= x[n] - a_1 w[n-1] - a_2 w[n-2] \\ y[n] &= b_0 w[n] + b_1 w[n-1] + b_2 w[n-2] \end{align}$$

  • How to plot the frequency response of the output with out using inbuilt commands in MATLAB? Also I want to implement the same in fixed point using 32 bit and plot the frequency reponse of it.
  • For plotting should I use freqz command or plot(abs(fft(my ouput))?. Both should give me same frequency response, but I am getting different responses,

command used is plot(abs(fft(my output)))

using freqz command

  • 2
    $\begingroup$ Your question is now much clearer, but now it would be good to know where you're stuck, because right now you're just stating the (homework) problem and you expect people to solve it for you. We're here to answer concrete questions that show some effort, not to provide complete solutions to exercises. $\endgroup$
    – Matt L.
    Feb 22, 2015 at 14:43
  • 1
    $\begingroup$ i'm just responding to the title and the equations (that i modified slightly to make them conform to convention). the equations depict the Direct Form II filter structure, which i would not recommend, especially for fixed point. $\endgroup$ Feb 22, 2015 at 16:56
  • 2
    $\begingroup$ well, @MattL., what the fixed-point DF2 suffers that the DF1 doesn't (let's assume the same $H(z)$ in both cases) is clipping due to the gain of the poles before that gain is mitigated by the gain reduction of the zeros. the counterpart problem the DF1 has if the accumulator is not double-wide, is that the quantization error due to the zeros is amplified by the gain of the poles. but if the DSP (or the code) maintains a double-wide accumulator, the DF1 does not suffer that problem and does not suffer the internal clipping problem specific to the DF2. $\endgroup$ Feb 22, 2015 at 20:17
  • 4
    $\begingroup$ so is your question why your first plot doesn't look exactly like your second plot? one is a linear:linear plot where half of it is above Nyquist and the other is a log:linear plot all below Nyquist. $\endgroup$ Feb 23, 2015 at 5:46
  • 2
    $\begingroup$ @robertbristow-johnson: It doesn't make sense to talk about frequency response when taking overflow and round-off noise into consideration (since that "frequency response" will be input signal dependent). However, coefficient quantization is relevant to discuss in this context and there will be a well defined frequency response with quantized coefficients (unless the poles move outside of the unit circle). So I guess my vote goes to Matt L. With that said, for a practical implementation signal representation is highly relevant, but it doesn't relate to the frequency response. $\endgroup$
    – Oscar
    Feb 23, 2015 at 10:32

1 Answer 1


setting aside the DF1 vs. DF2 issue (and we know there are several other forms besides those two, all with advantages and disadvantages), there is an answer, sans phase response, to the OP's original question here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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