1
$\begingroup$

I'm filtering a real signal with a single complex pole with a complex coefficient (a_re [real part] and a_im [imaginary part]), I also have a gain coefficient but I'm gonna leave it out for the sake of simplicity. The filter has two outputs, one for the real and another for the imaginary part. Here's the filter equation in time for both outputs

Real part output: $$y_1[n] = x_1[0] + a_{R} y_1[-1] - a_{I} y_2[-1]$$ Imaginary part output: $$y_2[n] = a_{I} y_1[-1] + a_{R} y_2[-1]$$

Where $n$ is the sample number, $x_1[0]$ is the real input, $a_{R}$ & $a_{I}$ are, respectively, the real and imaginary part of the coefficient, $y_1[-1]$ is the previous output of "real part output" and $y_2[-1]$ is the previous output of "imaginary part output".

So, I need to plot the frequency response based on the Z transform. I've already succeeded in dealing with the real version of all this (a real pole), and I'm struggling with the complex version. Anyway, the equation for the real pole is:

$$y[n] = x[0] + a y[-1]$$

Where $a$ is the coefficient of the real pole.

Now, the Z-transform of the real pole is:

$$\tag{1}H(z) = \dfrac{1}{ 1 - a z^{-1}}$$

Where, again, $a$ is the coefficient of the real pole.

In my code I am solving it and dealing with the z-transform in this way, the input of the function is the $a$ coefficient and the $\omega$ variable (which is the angular frequency in radians per sample). I'm only interested in getting the magnitude output, so I don't care about the phase response of the filter. Anyway, here is how I get it:

$a \rightarrow$ coefficient

$w \rightarrow$ angular frequency

$f_{R} = \cos(\omega)$; $\;\;\;\;f_{I} = \sin(\omega)$

$\mathbf{R} = 1 - a f_{R}$; $\;\;\mathbf{I} = -a f_{I}$

$\mathbf{Mag} = \sqrt{\mathbf{R}^{2} + \mathbf{I}^{2}}$

$H = \frac{1}{\mathbf{Mag}}$

The whole thing would be:

$$\tag{2}|H(z)| = \dfrac{1}{\sqrt{(1 - a \cos \omega)^2 + (-a \sin \omega)^2)}}$$

Now my trouble is adapting it to the complex version of this z transform, which is supposed to be the same formula as the real pole's z transform in Eq. (1), but I don't know how to adapt the formula/code for the complex pole. Bearing in mind that I want to have the frequency response of the two outputs (the real and imaginary part of the complex filter).

Hopefully, I'd like some help on reaching the frequency response from the coefficient as a function of angular frequency as I've written above for the real pole version of this in Eq.(2)!

Any thoughts, considerations, hints, help is highly welcome.

Thanks a lot

$\endgroup$
  • 1
    $\begingroup$ It would help a lot if you added some Latex formatting. $\endgroup$ – Matt L. Aug 23 '14 at 10:26
  • $\begingroup$ Your presentation of the problem suggests that you lack some rather important math tools like complex numbers, the actual definition of the z-transform or the magnitude response and basic algebra. Your understanding will be greatly increased if you take some time to study those. $\endgroup$ – Jazzmaniac Aug 23 '14 at 13:49
  • $\begingroup$ well, I'm studying, but even my teacher can't solve this problem, so it doesn't seem to be trivial and I really needed some help, could you point more specifically where you see a problem or just help out anyway? thanks $\endgroup$ – Alexandre Torres Porres Aug 23 '14 at 14:34
  • $\begingroup$ @AlexandreTorresPorres, if your teacher cannot solve this problem (and he claims competence in this field) then you should look for a new (and better) teacher. This problem is close to trivial if you understand the definitions involved. Matt's answer already gave you everything you need. I gave you subjects for self-studying. If there's anything else you need, please specify exactly what that would be and I will try my best to help. $\endgroup$ – Jazzmaniac Aug 23 '14 at 15:43
  • $\begingroup$ I've already specified in a comment to matt's answer as it's not everything I need yet, unfortunately $\endgroup$ – Alexandre Torres Porres Aug 23 '14 at 15:49
1
$\begingroup$

If I understood you correctly you want a formula for the magnitude of the frequency response of a filter with a single complex pole. As you've already noticed, the system function is

$$H(z)=\frac{1}{1-az^{-1}}\tag{1}$$

which is valid regardless of whether $a$ is real-valued or complex-valued. Let's assume that $a=a_r+ja_i$ is a complex-valued number. If we also assume that $|a|<1$ (i.e. the system is causal and stable), then we get the systems frequency response by replacing $z$ by $e^{j\omega}$ in (1):

$$H(e^{j\omega})=\frac{1}{1-ae^{-j\omega}}\tag{2}$$

Now you just have to compute the magnitude of (2). Using

$$|1-u|^2=1-2\text{Re}\{u\}+|u|^2$$

for any complex $u$, we get with $u=ae^{-j\omega}$ from (2)

$$|H(e^{j\omega})|=\frac{1}{\sqrt{1-2\text{Re}\{ae^{-j\omega}\}+|a|^2}}= \frac{1}{\sqrt{1-2(a_r\cos\omega+a_i\sin\omega)+|a|^2}}\tag{3}$$

EDIT:

This is how you can derive the transfer functions relating the real-valued input to the real part and the imaginary part of the output, respectively. Let $y(n)=y_r(n)+jy_i(n)$. Then you have the following two difference equations for the two real-valued output signals:

$$y_r(n)=x(n)+a_ry_r(n-1)-a_iy_i(n-1)\\ y_i(n)=a_ry_i(n-1)+a_iy_r(n-1)$$

Transforming these equations to the $\mathcal{Z}$-domain gives

$$Y_r(z)=X(z)+a_rz^{-1}Y_r(z)-a_iz^{-1}Y_i(z)\\ Y_i(z)=a_rz^{-1}Y_i(z)+a_iz^{-1}Y_r(z)$$

Now you have two equations for the two unknowns $Y_r(z)$ and $Y_i(z)$. After some algebra you arrive at

$$Y_r(z)=H_r(z)X(z)=\frac{1-a_rz^{-1}}{1-2a_rz^{-1}+(a_r^2+a_i^2)z^{-2}}X(z)\\ Y_i(z)=H_i(z)X(z)=\frac{a_iz^{-1}}{1-2a_rz^{-1}+(a_r^2+a_i^2)z^{-2}}X(z)\tag{4}$$

Note that even though

$$H(e^{j\omega})=H_r(e^{j\omega})+jH_i(e^{j\omega})$$

$H_r(e^{j\omega})$ and $H_i(e^{j\omega})$ are not the real and imaginary parts of the total frequency response $H(e^{j\omega})$ of the complex-valued system because they are both themselves complex-valued. You can obtain the magnitudes of the frequency responses by computing the magnitudes of $H_r(e^{j\omega})$ and $H_i(e^{j\omega})$ as given in (4), i.e. by replacing $z$ by $e^{j\omega}$ and computing the magnitudes of the two complex functions.

Another option is to express the frequency responses $H_r(e^{j\omega})$ and $H_i(e^{j\omega})$ using the total frequency response $H(e^{j\omega})$ (2):

$$H_r(e^{j\omega})=\frac12[H(e^{j\omega})+H^*(e^{-j\omega})]\\ H_i(e^{j\omega})=\frac{1}{2j}[H(e^{j\omega})-H^*(e^{-j\omega})]\tag{5}$$

From (5), the magnitudes can be written as

$$|H_r(e^{j\omega})|=\frac{1}{2}\sqrt{|H(e^{j\omega})|^2+2\text{Re}\{H(e^{j\omega})H(e^{-j\omega})\}+|H(e^{-j\omega})|^2\}}\\ |H_i(e^{j\omega})|=\frac{1}{2}\sqrt{|H(e^{j\omega})|^2-2\text{Re}\{H(e^{j\omega})H(e^{-j\omega})\}+|H(e^{-j\omega})|^2\}}$$

where $|H(e^{j\omega})|$ is given by (3).

EDIT 2:

Here's some Matlab/Octave code using equation (4) to plot the different transfer functions. $|H_r(e^{j\omega})|$ and $|H_i(e^{j\omega})|$ are of course symmetrical because they correspond to real-valued systems, whereas $|H(e^{j\omega})|$ is not due to the complex pole.

w = linspace(0,2*pi,300);          % frequency vector
ar = .4; ai = -.3; a = ar+j*ai;    % complex pole
u = exp(-j*w);                     % u = z^(-1)
Hr = (1-ar*u)./(1-2*ar*u+(ar^2+ai^2)*u.^2);
Hi = (ai*u)./(1-2*ar*u+(ar^2+ai^2)*u.^2);
H = 1./(1-a*u);
plot(w/pi,abs(Hr),w/pi,abs(Hi),w/pi,abs(H))
legend('Hr', 'Hi', 'H');

enter image description here

EDIT 3:

If you need to split the numerators and denominators of (4) into real and imaginary parts, here's what you get:

$$H_r(e^{j\omega})=\frac{1-a_r\cos\omega+ja_r\sin\omega}{\left[1-2a_r\cos\omega+(a_r^2+a_i^2)\cos(2\omega)\right]+j\left[2a_r\sin\omega-(a_r^2+a_i^2)\sin(2\omega)\right]}\\ H_i(e^{j\omega})=\frac{a_i\cos\omega-ja_i\sin\omega}{\left[1-2a_r\cos\omega+(a_r^2+a_i^2)\cos(2\omega)\right]+j\left[2a_r\sin\omega-(a_r^2+a_i^2)\sin(2\omega)\right]}$$

$\endgroup$
  • $\begingroup$ @AlexandreTorresPorres: I edited my answer to add the two transfer functions relating the input signal to the real and imaginary parts of the output signal. I think this is what you wanted. $\endgroup$ – Matt L. Aug 23 '14 at 15:56
  • $\begingroup$ Great, I edited my post too now that you've cleared a lot. The formula in (4) would be enough. Unfortunately my math is bad I needed a more straight forward formula as a function of angular frequency "w", I'm particularly having trouble with "zˆ-2" - Eq. (5) seems way over my head. Like in my original posting for the real pole, It'd be good to find "R" and "I" to then compute magnitude and phase from it. $\endgroup$ – Alexandre Torres Porres Aug 24 '14 at 2:10
  • $\begingroup$ btw, I didn't get what "Re" stands for in your last equations, and there seems to have a braces open $\endgroup$ – Alexandre Torres Porres Aug 24 '14 at 2:35
  • $\begingroup$ @AlexandreTorresPorres: It obviously means real part of a complex number. I suggest you first to read through some basics of complex analysis. Even wikipedia is better than nothing. $\endgroup$ – jojek Aug 24 '14 at 9:00
  • $\begingroup$ @AlexandreTorresPorres: In (4) just replace $z$ by $e^{j\omega}$ to get two complex-valued functions of $\omega$ and simply plot their magnitude. Which software do you use? You don't need an analytical expression for the magnitude, you can just use 'abs()' of the complex function and plot it. Not sure if I understand your problem. $\endgroup$ – Matt L. Aug 24 '14 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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