Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Filter problem

  1. May 8, 2010 #1
    I am trying to graph the frequency spectrum of a signal over time. To do this, for each frequency I use a filter defined by the following equation:
    [tex]y_n = Ae^{i\omega_0}y_{n-1} + x_n[/tex]
    This has a frequency response of [tex]\frac 1 {\sqrt{\left(1-A\right)^2+2A\left(1-cos\left(\omega-\omega_0\right)\right)}}[/tex], which peaks at [tex]\omega_0[/tex].

    Now, for every m steps I want to find out how much [tex]x_n[/tex] contributed to [tex]|y_n|[/tex] during the last m steps. I define [tex]\widehat{y}_n=H\left[n\right]\left|y_n\right|[/tex], where n=0 is the first of the last m steps and H is the unit step function, and I let [tex]\widehat{x}[/tex] be the contribution of x to |y|, which I assume to be constant for the m samples under consideration. This gets me the equation [tex]\widehat{y}_n=A\widehat{y}_{n-1}+\delta\left[n\right]A\left|y_{-1}\right|+H\left[n\right]\widehat{x}[/tex].

    The Z-transform of this equation is:
    In other words,
    This can be written as:
    [tex]\widehat{Y}\left(z\right)=\frac C{1-z^{-1}}+\frac D{1-Az^{-1}}=\frac{C\left(1-Az^{-1}\right)+D\left(1+z^{-1}\right)}{\left(1-z^{-1}\right)\left(1-Az^{-1}\right)}[/tex]
    From the two equations about, [tex]A\left|y_{-1}\right|+\widehat{x}-A\left|y_{-1}\right|z^{-1}=C+D-ACz^{-1}-Dz^{-1}[/tex] for all z, and we must have [tex]A\left|y_{-1}\right|+\widehat{x}=C+D[/tex] and [tex]Ay_{-1}=AC+D[/tex].
    The inverse transform of [tex]\frac C{1-z^{-1}}+\frac D{1-Az^{-1}}[/tex] is [tex]H\left[n\right]\left(C+DA^n\right)[/tex]. So, we have [tex]C+DA^{m-1}=\widehat{y}_{m-1}[/tex].
    This gives:
    [tex]A\left|y_{-1}\right|-\frac{\widehat{y}_{m-1}}{A^{m-1}}=C\left(A-\frac 1{A^{m-1}}\right)[/tex]

    However, when I apply the last formula to the result of the first filter in my program, I don't get [tex]\widehat{x}[/tex]. If x is 0, then [tex]\widehat{x}[/tex] should be 0 as well, but it isn't. The formula looks correct. I have tried with a value of m as low as 2, but it still doesn't work. What could be the problem.
    Last edited: May 8, 2010
  2. jcsd
  3. May 8, 2010 #2
    Oh, nevermind. I had a bug in the program where I accidentally used [tex]\widehat{x}[/tex] for [tex]\left|y_{-1}\right|[/tex] for the next iteration.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook