# Plotting the frequency response of a FIR filter

I am trying to figure out the mechanics of plotting the frequency response of a FIR filter. For example, I have used an algorithm (Parks-McClellan), to generate a low pass FIR filter with an even number of coefficients. I've got 34 tap values. Now I want to show the frequency response of this configuration in a normalized frequency 0 ... 1.0 (Fs) graph. The literature says, "The frequency response of the filter is computed by passing the array of coefficients through the discrete Fourier transform (DFT)." The text goes on to show this nice smooth graph, plotting magnitude vs frequency from 0.0 to 1.0. I would like to reproduce that graph.

So I sent it through my DFT code, well a 34 point DFT generates a very blocky DFT and it looks nothing like the graphic. I wanted more points of the DFT (between 0 and 34) and tried adding fractional points 0.0, 0.1, 0.2, .. 34.0) and got a very "loopy" DFT with lots of humps (and also not at all like the graphic), I tried "upsampling" adding zeros between the values, still no joy. I tried allowing the tap sequence to repeat, no joy. So I'm really curious how its done. Sending it to the MATLAB plot function produces the expected graph, so I have some confidence the data is good. Just my understanding of the mechanics of how to get the higher resolution graph are incomplete.

• dunno why you were downvoted. that wasn't very friendly. i'll counter it with an up. anyway, take your 34 tap values and zero-pad it to a length of, say, 1024. then DFT that FIR. you'll get a nice smooth result. – robert bristow-johnson May 24 '19 at 20:09
• also, if you already are using Matlab, check the documentation for the filter() function, which will directly plot the frequency response. – Juancho May 24 '19 at 20:23
• Thanks @robertbristow-johnson that was super helpful! That was exactly the missing clue I needed. – Turloch May 24 '19 at 22:05
• FWIW, a collegue pointed out chapter 5 of "Understanding Digital Signal Processing" where Richard Lyons writes: If we take the five h(k) coefficient values of 1/5 and append 59 zeros, we have the sequence depicted in Figure 5-8(a). Performing a 64-point DFT on that sequence, and normalizing the DFT magnitudes, gives us the filter’s frequency magnitude response |H(m)| in Figure 5-8(b) and phase response shown in Figure 5-8(c).†† H(m) is our old friend, the sin(x)/x function from Section 3.13." – Turloch May 24 '19 at 23:28