# 6.7: Numerical Experiment (Frequency Response of First-Order Filter)

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$ $$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$ $$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$ $$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$$$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

Consider the exponential moving average filter

$$x_{n}=\sum_{k=0}^{\infty} a^{k} u_{n-k ;} \quad a=0.98$$

1. Write out a few terms of the sum to show how the filter works.
2. Write $$x_n$$ as a recursion and discuss the computer memory required to implement the filter.
3. Compute the complex frequency response $$H(e^{j\theta})$$ for the filter
4. Write a MATLAB program to plot the magnitude and phase of the complex frequency response $$H(e^{j\theta})$$ versus $$\theta$$ for $$\theta =−\pi$$ to $$+\pi$$ in steps of $$\frac{2\pi}{64}$$ Do this for two values of $$a$$, namely, $$a=0.98$$ and $$a=-0.98$$. Explain your findings.
5. Write a MATLAB program to pass the following signals through the filter when $$a=0.98$$:
1. $$u_{n}=\delta_{n}$$
2. $$u_{n}=\xi_{n}$$
3. $$u_{n}=\xi_{n} \cos \frac{2 \pi}{64} n$$
4. $$u_{n}=\xi_{n} \cos \frac{2 \pi}{32} n$$
5. $$u_{n}=\xi_{n} \cos \frac{2 \pi}{16} n$$
6. $$u_{n}=\xi_{n} \cos \frac{2 \pi}{8} n$$
7. $$u_{n}=\xi_{n} \cos \frac{2 \pi}{4} n$$
8. $$u_{n}=\xi_{n} \cos \frac{2 \pi}{2} n$$

Plot the outputs for each case and interpret your findings in terms of the complex frequency response $$H(e^{j\theta})$$. Repeat step 5 for $$a=-0.98$$. Interpret your findings.

This page titled 6.7: Numerical Experiment (Frequency Response of First-Order Filter) is shared under a CC BY 3.0 license and was authored, remixed, and/or curated by Louis Scharf (OpenStax CNX) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.