# how to design LPH and HPF from APF

I came across a concept that says we can design LPH and HPF from APF when the transfer function of the two APFs given as

\begin{align}A_0(z)&=1\\ A_1(z)&=\frac{-a+z^{-1}}{1-az^{-1}}\\\\ H_{LP}(z)&=A_0(z)+A_1(z)\\ H_{HP}(z)&=A_0(z)-A_1(z)\end{align}

i tried to implement this in matlab but i did not get the desired frequency response..kindly help me with the matlab code for the same..

• Your A1 formula is ambiguous. Please add more () to make clear what you divide by which (come on, this is basic "how to write down a formula"). Commented Jan 16, 2016 at 14:27
• i didnt understand what is the ambiguity in A1..are you asking me the value for a?? Commented Jan 16, 2016 at 18:13
• With Gilles edit, it's now clear that you meant A1 = (-a+z^(-1))/(1-az^(-1)) with your formula, and not A1= -a + (z^(-1))/(1-az^(-1)), which obviously is something completely different! Commented Jan 17, 2016 at 10:15
• but i did not get the desired frequency response: What did you get instead? Where's your Matlab code? Please make it easy to answer your question! Commented Jan 17, 2016 at 10:24
• Does your title how to design LPH and HPF from APF really reflect your question well? I feel your question is about understanding and analyzing the resulting filter, not designing it. Commented Jan 17, 2016 at 10:54

Since you don't say what response you're actually getting from Matlab, this is all guesswork.

So let's do the basics: A little formula juggling.

\begin{align}A_0(z)&=1\\ A_1(z)&=\frac{-a+z^{-1}}{1-az^{-1}}\\[4em] H_{LP}(z)&=A_0(z)+A_1(z)\\ &= 1 + \frac{-a+z^{-1}}{1-az^{-1}}\\ &= \frac{{1-az^{-1}}-a+z^{-1}}{1-az^{-1}}\\ &= \frac{(1-a)\quad +\quad (1-a)z^{-1}}{1-az^{-1}}\\[4em] H_{HP}(z)&=A_0(z)-A_1(z)\\ &= 1 - \frac{-a+z^{-1}}{1-az^{-1}}\\ &= \frac{{1-az^{-1}}+a-z^{-1}}{1-az^{-1}}\\ &= \frac{(1+a)\quad +\quad (-1-a)z^{-1}}{1-az^{-1}} \end{align}

So, taken from these formulas, the filter coefficients for $H_{LP}$ are $b=[1-a,1-a]$, $a=[1,-a]$, and for $H_{HP}$ it's $b=[1+a,-1-a]$, $a=[1,-a]$ for the canonical form of recursive filters

$$H= \frac{\sum\limits_{i=0}^N b_i z^{-i}}{\sum\limits_{i=0}^M a_i z^{-i}}\text.$$

Plugging that into scipy's scipy.signal.freqz for different $a$ yielded (abscissa: normalized frequency $\in[0,\pi[$, ordinate: magnitude):

$H_{LP,a}$ for $a\in\{0,0.1,\dots,0.9,1\}$:

$H_{HP,a}$ for $a\in\{0,0.1,\dots,0.9,1\}$:

which both very nicely match the terms low and high pass filters, respectively.

• what is that scipy.signal.freqz..i didnt find that function in matlab documentation.. Commented Jan 19, 2016 at 14:40
• unfortunately i am not able to copy the matlab code which i wrote..i have used the coefficients which you suggested but though i am getting the response. its not varying when i change the parameter a.. Commented Jan 19, 2016 at 14:49
• here is my mail id: [email protected] you kindly send me the matlab code..thanks :) Commented Jan 19, 2016 at 14:50
• @pavansunder: why can't you share your Matlab code? This sounds like the lamest excuse to get someone else to do your homework ever. Commented Jan 19, 2016 at 16:32
• i tried to copy and paste my matlab code....but was unable to do..can u share your mail id so that i ll send my code.. Commented Jan 19, 2016 at 17:48