2
$\begingroup$

I am trying to calculate manually the phase of the frequency response of an LTI system as a function of frequency and plot the results. The original system is described as $y[n]=0.1(x[n]-x[n-1]+x[n-2]$, which I was able to write the frequency response $H(e^{j\hat{\omega}})=0.1(1-e^{-j\hat{\omega}}+e^{-j\hat{\omega}2})$.

I used MATLAB to plot the phase using the code below:

tt = -pi : 1/200 : pi;
H = 0.1*(1-exp(-j*tt)+exp(-j*tt*2));

plot(tt, angle(H))

And the output was as shown below:

Phase as shown in MATLAB

This does not match the result I got by calculating as shown below:

$0.1(1-e^{-j\hat{\omega}}+e^{-j\hat{\omega}2})$

$0.1e^{-j\hat{\omega}}(e^{j\hat{\omega}}-1+e^{-j\hat{\omega}})$

$0.1e^{-j\hat{\omega}}(2\cos(\hat{\omega})-1)$

$0.1(\cos(\hat{\omega})-j\sin(\hat{\omega}))(2\cos(\hat{\omega})-1)$

$0.1(2\cos^2(\hat{\omega})-\cos(\hat{\omega}) - 2j\sin(\hat{\omega})\cos(\hat{\omega})+j\sin(\hat{\omega}))$

$0.1\left(\left(2\cos^2(\hat{\omega})-\cos(\hat{\omega})\right)+j\left(- 2\sin(\hat{\omega})\cos(\hat{\omega})+\sin(\hat{\omega})\right)\right)$

$\theta = \tan^{-1}\left(\dfrac{-2\sin(\hat{\omega})\cos(\hat{\omega})+\sin(\hat{\omega})}{2\cos^2(\hat{\omega})-\cos(\hat{\omega})}\right)$

$\theta = \tan^{-1}\left(\dfrac{-\sin(\hat{\omega})\left(2\cos(\hat{\omega})-1\right)}{\cos(\hat{\omega})\left(2\cos(\hat{\omega})-1\right)}\right)$

$\theta = \tan^{-1}\left(-\tan(\hat{\omega})\right)$

enter image description here I am not sure if I am misunderstanding how to calculate the phase function, or if there is an error in my work somewhere. Is this the correct way to calculate the phase? If so, is there an error somewhere that I am missing?

$\endgroup$

1 Answer 1

2
$\begingroup$

I assume that you used the arctangent function to evaluate the result of your calculations. That's the problem. You cannot compute the argument of a complex number by using the arctangent function, unless you're lucky and the argument is in the range $(-\pi/2,\pi/2)$. Note that when you divide the imaginary part and the real part before computing the arctangent, the individual signs get lost. That's why all arguments are mapped to the range $(-\pi/2,\pi/2)$. So you need to use the real and imaginary parts directly, without dividing them. This can be done with the atan2 function. It will give you the correct argument in the range $(-\pi,\pi]$.

Concerning your calculation, you did too much work (which also didn't give you any extra information). You should have stopped after obtaining

$$H(e^{j\omega})=0.1e^{-j\omega}\left(2\cos\omega-1\right)\tag{1}$$

Since the term $2\cos\omega-1$ is real-valued, you can see that the phase is basically linear, but that it jumps by $\pm\pi$ when that real-valued term changes sign, which happens at $\cos\omega=\frac12$, i.e., at $\omega=\pm\pi/3$. You can see this in your first plot. The jumps in the second plot are not real phase jumps; they just occur due to the use of the arctangent function.

So from $(1)$, the result of the calculation could be written as

$$\phi(\omega)=\begin{cases}-\omega,&-\pi/3<\omega<\pi/3\\-\omega+\pi,&\pi/3<\omega\le\pi\\-\omega-\pi,&-\pi<\omega<-\pi/3\end{cases}$$

where I chose the sign of the phase jump such that the phase $\phi(\omega)$ remains in the range $(-\pi,\pi]$, just like the return value of the angle function.

$\endgroup$
3
  • $\begingroup$ Thank you…this answer is so clear! I wish my professor explained the atan function 🙄 $\endgroup$ Commented Nov 1, 2023 at 12:27
  • $\begingroup$ If 2cos(omega)-1 was not all real, what would be different? $\endgroup$ Commented Nov 1, 2023 at 12:33
  • 1
    $\begingroup$ @SamanthaGarcia: Then it would contribute to the phase in a more complex way. If the expression for the transfer function is in the form $A(\omega)e^{j\phi(\omega)}$ with real-valued $A(\omega)$ then you can directly see the phase $\phi(\omega)$, apart from jumps of $\pi$ when/if $A(\omega)$ changes sign. Think of the magnitude/phase representation of a complex number: $z=|z|e^{j\phi}$, with the only difference that in your case you don't have the magnitude but a bipolar real-valued function. $\endgroup$
    – Matt L.
    Commented Nov 1, 2023 at 12:36

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.