0
$\begingroup$

It seems I've forgotten much of the details of signal processing theory when attempting to reconstruct algorithms for extracting FFT-like amplitude/phase information from examples online. I was particularly lost when I could not reconstruct the negative sign of the amplitude/phase of one of the sinusoids I had summed into a larger function. The magnitude of the complex numbers that results from a typical FFT inherently involves an absolute value (squaring, summing, square rooting); eventually I realized it would be contained in the phase information.

The question is "with a signal formed of a sum of sinusoidals, one of which having a negative amplitude and possibly negative phase, how does one reconstruct the amplitude/phase information including sign after computing a frequency transform (Geortzel or FFT) of that signal?"

I multiply the magnitude by the ratio of sin of the phase to the absolute value of the sin of the phase.

And here is sum MATLAB code

Fs=1024;
Ts = 1/Fs;
N = 1024;
t = Ts*(0:N-1)';
f= [8 13 17];

x = 10.25*sin(2*pi*f(1)*t)+5.89*sin(2*pi*(f(2))*t)-13.94*sin(2*pi*(f(3))*t);

freqIndices=round(f/Fs*N)+1;
y = goertzel(x,freqIndices);

phase = angle(y)+pi/2;

stem(f,(abs(y/((N)/2)).*(sin(abs(phase))./abs(sin(abs(phase)))))');

It's just not quite working for the sinusoidal with frequency f(3) when I add a phase in (with negative or positive value).

$\endgroup$

1 Answer 1

1
$\begingroup$

"with a signal formed of a sum of sinusoidals, one of which having a negative amplitude and possibly negative phase, how does one reconstruct the amplitude/phase information including sign after computing a frequency transform (Geortzel or FFT) of that signal?"

The question as posted seems to be based on a misleading model of how this actually works. The Discrete Fourier Transform (DFT), which is what Goertzel is implementing, expresses a time domain signal as the sum of weight complex sine waves. The Fourier coefficients are complex too: the have magnitude and a phase, i.e.

$$X[k] = A_k \cdot e^{j\varphi}, X[k] \in \mathbb{C}, A_k \in \mathbb{R}, A_k \ge 0, \varphi \in \mathbb{R}$$

The magnitude is always positive and the phase is an angle (typically from $[-\pi, \pi]$) and not just a binary plus/minus.

Disclaimer: for the rest of the discussion we'll ignore spectral leakage.

For a cosine the phase of the DFT will simply be zero. For a sine it's $-\pi/2$ for a negative sine it's $-\pi/2$ and for a negative cosine it's $-\pi$ or $+\pi$ (which is the same angle).

This is simply a consequence of

$$ \cos(\omega t) = -\cos(\omega t - \pi) = \sin(\omega t - \pi/2) = -\sin(\omega t + \pi/2) $$

The different versions are just phase shifts of each other.

That's exactly what your code has correctly produced. If you look at angle(y) you will get $[-\pi/2, -\pi/2, +\pi/2]$ which indicates "sine, sine, neg. sine"

$\endgroup$

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .