---
title: My DSP Lab - 02
---
# ELEC4621 DSP Lab 2
This article is to share the lab note and results for my DSP course at UNSW (ELEC4621)
## Introduction
In this lab, it continues with the input signal in lab1 (The sunspot data), and an addtional all-zero filter. The filter would be analysed with its impulse response and would be applied to the sunspot data.
## Filter
A fifth order all-zero filter is given
\begin{gather*}
H(z)=(\frac{z-r_1}{z})(\frac{z^2-2r_2\cos\theta_{2}+r_2^2}{z^2})(\frac{z^2-2r_3\cos\theta_{3}+r_3^2}{z^2})
\end{gather*}
where
\begin{gather*}
r_1=e^{-\frac{1}{8}}, r_2=r_3=0.9, \theta_2=0.6\pi, \theta_3=0.85\pi
\end{gather*}
### Impluse Response
Since it is an all-zero filter, the impulse response can be easily calculated by multipling the z-transform polynomial.
\begin{split}
H(z)&=(\frac{z-r_1}{z})(\frac{z^2-2r_2\cos\theta_{2}+r_2^2}{z^2})(\frac{z^2-2r_3\cos\theta_{3}+r_3^2}{z^2})\\
&=(1-r_1z^{-1})(1-2r_2\cos\theta_{2}z^{-2}+r_2^2z^{-2})(1-2r_3\cos\theta_{3}z^{-2}+r_3^2z^{-2})\\
&=1+1.2775z^{-1}+0.6059z^{-2}-0.4673z^{-3}-0.8879z^{-4}-0.579z^{-5}
\end{split}
The z-transform of an impulse $X(z) = Z(\delta[n])=1$
Thus, the impulse response is
\begin{split}
Y(z)&=X(z)H(z) \\&= 1+1.2775z^{-1}+0.6059z^{-2}-0.4673z^{-3}-0.8879z^{-4}-0.579z^{-5}
\end{split}
### Frequency Response

With the in-built function ```freqz()```, the magnitude and phase response can be obtained.
#### Magnitude
By using the log annotation, the gain of this filter in different frequency band is shown. The frequency below 0.5
### Sampling and Reconstruction
### Quantisation Effects
## Appendix
My code: