Graphing Frequency Spectrum of Signal Over Time

Click For Summary
SUMMARY

This discussion focuses on graphing the frequency spectrum of a signal over time using a specific filter equation: y_n = Ae^{i\omega_0}y_{n-1} + x_n. The frequency response is defined as \frac{1}{\sqrt{(1-A)^2 + 2A(1-\cos(\omega - \omega_0))}}, which peaks at \omega_0. The user encountered an issue where the calculated contribution \widehat{x} did not yield expected results, ultimately identifying a programming bug where \widehat{x} was incorrectly assigned to \left|y_{-1}\right|. This highlights the importance of debugging in signal processing implementations.

PREREQUISITES
  • Understanding of digital signal processing concepts
  • Familiarity with Z-transforms and their applications
  • Proficiency in programming for signal processing (e.g., Python, MATLAB)
  • Knowledge of filter design and frequency response analysis
NEXT STEPS
  • Study Z-transform applications in signal processing
  • Learn about digital filter design techniques
  • Investigate debugging strategies for signal processing algorithms
  • Explore visualization tools for frequency spectrum analysis
USEFUL FOR

Signal processing engineers, software developers working on audio analysis, and researchers in the field of digital signal processing will benefit from this discussion.

Gigasoft
Messages
59
Reaction score
0
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:
y_n = Ae^{i\omega_0}y_{n-1} + x_n
This has a frequency response of \frac 1 {\sqrt{\left(1-A\right)^2+2A\left(1-cos\left(\omega-\omega_0\right)\right)}}, which peaks at \omega_0.

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

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

However, when I apply the last formula to the result of the first filter in my program, I don't get \widehat{x}. If x is 0, then \widehat{x} 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:
Physics news on Phys.org
Oh, nevermind. I had a bug in the program where I accidentally used \widehat{x} for \left|y_{-1}\right| for the next iteration.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 36 ·
2
Replies
36
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
10K
  • · Replies 2 ·
Replies
2
Views
10K