3
$\begingroup$

So I have the transfer function:

$$H[z] = 1 + \sqrt{2}z^{-1} + z^{-2} $$

And I have to evaluate $H(e^{j\omega})$ for $\omega= 0, \pi/4, \pi/4 \ldots$

I have done the calculations manually using Euler's formula, but now the assignment is asking me to compare these plots with the plots using freqz in MATLAB. I can't seem to find instructions on how I can do that with this type of transfer function.

$\endgroup$
2
  • $\begingroup$ I can't even :D So, hint: any number is $x$ is representable by $\frac xy$ for a specific number $y$. Always. What's that $y$? $\endgroup$ Commented Nov 15, 2016 at 23:32
  • $\begingroup$ From what I can see, you have the numerator (b) of your filter. So simply plug it to freqz and voila. $\endgroup$
    – jojeck
    Commented Nov 15, 2016 at 23:33

2 Answers 2

2
$\begingroup$

You simply specify a = 1 (because the denominator equals $1$). So you get

b = [1,sqrt(2),1];
a = 1;
N = 512;
[H,w] = freqz(b,a,N);

You can compare this to the analytical solution:

H2 = 1 + sqrt(2)*exp(-1i*w) + exp(-1i*2*w);
max(abs(H2-H))    % 8.0825e-16
$\endgroup$
2
  • $\begingroup$ Sorry I'm really new to this, but what is N representing here? $\endgroup$
    – Fred
    Commented Nov 22, 2016 at 15:49
  • $\begingroup$ @Freddie: It's the number of (equidistant) frequency points at which the frequency response is evaluated. Just check out the Matlab documentation of freqz. $\endgroup$
    – Matt L.
    Commented Nov 22, 2016 at 17:52
0
$\begingroup$

For the evaluation only at specific frequencies, you need to specify the frequency vector with at least two frequencies in it (see MATLAB's freqz). Below is the MATLAB code for the evaluation at the frequencies $\omega = 0, \pi/4, \pi/2, 3\pi/4, \text{and}\ \pi$.

>> [h, w] = freqz([1, sqrt(2), 1], 1, [0 , pi/4, pi/2, 3*pi/4 pi])

h =

   3.4142 + 0.0000i   2.0000 - 2.0000i   0.0000 - 1.4142i  -0.0000 - 0.0000i   0.5858 + 0.0000i


w =

         0    0.7854    1.5708    2.3562    3.1416

>> 

For the visualization of the results above, see the magnitude response, i.e. $20\log_{10}\left(\lvert H\left(\omega\right)\rvert\right)$, plotted below with the five frequencies marked in red.

enter image description here

Note that for $\pm 3\pi/4$ you have that (see code results above) $$ H\left(\pm \frac{3\pi}{4}\right) = 0\implies 20\log_{10}\left(\bigg\lvert H\left(\pm \frac{3\pi}{4}\right)\bigg\rvert\right) = -\infty $$ Also from the fact that the zeros are at $$ z = -\frac{\sqrt{2}}{2}\pm j\frac{\sqrt{2}}{2}\quad\text{with}\quad z = e^{j\omega} $$ The corresponding magnitude for $\omega = 3\pi/4$ is not shown on the single-sided magnitude response plot above but you can see the asymptotic trend at $3\pi/4$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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