# Calculation frequency response of digital filter with known structure

Short question
What are main stages (steps) of calculation frequency response of digital filter by their structure?

Detailed question
Let suppose that there is discrete FIR filter with known structure which is implemented in programming language (for instance with structure which shown in picture):

              +-----+   +-----+
|     |   |     |
x (k) >---+---|  T  |---|  T  |
|   |     |   |     |
|   +-----+   +-----+
|      |         |
|   +-----+      |
|   |     |      |
|   | x 2 |      |
|   |     |      |
|   +-----+      |
|      |         |
|   +----------------+   +-----+
|   |       ___      |   |   1 |
\---|       \        |---| x - |---> y (k)
|       /__      |   |   4 |
+----------------+   +-----+


It is possible to pass into the filter input signal (as vector of integers which describe magnitude), like this:

in [0, 0, 0, 0, 4, 0, 0, 0, 0, 0]


Which describe signal with following magnitude:

             |
x (k)        |
|
. . . . . | . . . .

k  9 8 7 6 5 4 3 2 1 0


And get corresponding output signal, like this:

out [0, 0, 0, 0, 1, 2, 1, 0, 0, 0]


Which describe signal with following magnitude:

y (k)
|
. . . | | | . . . .
k  9 8 7 6 5 4 3 2 1 0


Question is how to calculate frequency response of the filter (by stages)?

Notes
With known input and output signals we can calculate transfer function of the filter by their images of Laplace transform (z-transform for discrete signals):
1. $$X(z) = \mathcal{L} \{x(k)\}$$
2. $$Y(z) = \mathcal{L} \{y(k)\}$$
3. $$H(z) = Y(z) / X(z)$$
And after if we get Fourier transform from transfer function we will get AFC:
4. $$FR = \mathcal{F} \{H(z)\}$$
Is it correct?

• A small formality on your figure. $x(k)$ and $y(k)$ are in the time domain, while $z^{-1}$ indicates frequency domain. Better to go with either $X(z)$ and $Y(z)$ or change $z^{-1}$ to $T$. Although not uncommon and totally understandable to mix, it may be easier to understand the basics by using a consistent notation. – Oscar Mar 2 '15 at 15:41
• @Oscar, Thanks for suggestion, I've fixed it. – Gluttton Mar 2 '15 at 16:02

For the given system you can write down the input-output relation as

$$y[k]=\frac14\left(x[k]+2x[k-1]+x[k-2]\right)\tag{1}$$

because $T$ (or $z^{-1}$) denotes a delay element, which delays its input by one sample interval. The $\mathcal{Z}$-transform of (1) is (assuming zero initial conditions)

$$Y(z)=\frac14\left(X(z)+2X(z)z^{-1}+X(z)z^{-2}\right)=\frac{X(z)}{4}\left(1+2z^{-1}+z^{-2}\right)\tag{2}$$

From (2) you get the system's transfer function

$$H(z)=\frac{Y(z)}{X(z)}=\frac14\left(1+2z^{-1}+z^{-2}\right)\tag{3}$$

Since the system is stable (any FIR filter is), the frequency response can be obtained by evaluating the transfer function on the unit circle $z=e^{j\omega}$:

$$H(e^{j\omega})=\frac14\left(1+2e^{-j\omega}+e^{-2j\omega}\right)\tag{4}$$

You also could have arrived at (4) by writing down the impulse response from (1)

$$h[k]=\frac14\left(\delta[k]+2\delta[k-1]+\delta[k-2]\right)\tag{5}$$

and taking the (discrete-time) Fourier transform, which also results in (4).

Finally, a few notes concerning misconceptions in your question:

• $\mathcal{L}$ usually denotes the Laplace transform, which is defined for continuous functions. $X(z)$ is the $\mathcal{Z}$-transform of the sequence $x[k]$, which can be written as $X(z)=\mathcal{Z}\{x[k]\}$.

• The frequency response of a linear time-invariant (LTI) system is the Fourier transform of the system's impulse response: $H(e^{j\omega})=\mathcal{F}\{h[k]\}$, not the Fourier transform of $H(z)$ (which you seem to think, judging from the last equation in your question).

• Thank you for answer and for correction me in my misconceptions! Just to be sure that I understand your answer correct. Frequency response of FIR filter can be obtained by information about its structure or impulse response. Frequency response can be obtained by structure of filter in three steps. 1. Find difference equation by structure of filter. 2. Obtain transfer function by difference equation using Z-transform. 3. Frequency response can be obtained by simple substitution Z on e^jw in transfer function. Also frequency response can be obtained as Fourier transform of impulse response. – Gluttton Mar 2 '15 at 15:32
• And one question: do you miss operation of modulus in right part of formula ? – Gluttton Mar 2 '15 at 15:32
• Totally correct answer, but to find the frequency response, I'd go with the z-transform directly. It is (most of the time) quite straightforward to state the equations for each node/partial result, merge them into one equation, like (2), and then write it on $\frac{Y(z)}{X(z)}$-form like (3). This is typically easier, in my opinion, when you get more complicated algorithms. So no need for step 1 in your summary as it is equivalent to step 2. – Oscar Mar 2 '15 at 15:38
• @Gluttton: It looks like you understood the answer correctly. And there's no absolute value missing in (4) because the frequency response is a complex function. You can compute its magnitude and phase if desired, but you need both to completely characterize the system. – Matt L. Mar 2 '15 at 17:42
• And there's no absolute value missing, I try to check this algorithm to obtain frequency response of the MTI delay line canceler. Its response is well known and equal 2 abs (sin (wT/2)) (for 2 pulse delay line) and 4 sin (wT/2)^2 (for 3 pulse delay line) Pg 20 and 30. When I build plots in Octave (tool similar with Matlab) in terms of Z I will get not the same responses as known. But if I add abs there are became definitely the same. Sorry for make you forced to load in RADAR topic. – Gluttton Mar 2 '15 at 21:29