Computes the Discrete Fourier Transform using the Goertzel algorithm.
GOERTZELDFT(series, freq)
series |
- |
Any series or multi-column table. |
freq |
- |
A series, the frequency values of the output transform. |
A complex series or table in Cartesian form.
W1: {1, 2, 3}
W2: fft(w1)
W3: xvals(w2)
W4: goertzeldft(w1, w3)
W2 == {6.0 + 0.0i, -1.5 + 0.8660i, -1.5 - 0.8660i}
W4 == {6.0 + 0.0i, -1.5 + 0.8660i, -1.5 - 0.8660i}
W1 contains a 3 point time domain series.
W2 computes the 3 point FFT of W1.
W3 contains the frequency values of the FFT.
W4 computes the DFT of W1 using the Goertzel algorithm. The values are essentially identical as W2 because the output frequency values are the same.
W1: gtri(100, 1/100)^2
W2: mag(fft(w1));table
W3: mag(goertzeldft(w1, {0, 1, 2, 8}));table
W4: xvals(w2);table
W5: xtoidx(W4, {0, 1, 2, 8});table
W6: abs(w2[w5] - w3)
W1 contains a 100 sample time domain series.
W2 computes the magnitude of the FFT of W1 displayed as a table.
W3 computes the DFT at frequencies 0, 1, 2, and 8 Hz displayed as a table.
W4 contains the frequencies of the full FFT.
W5 maps the frequencies to indices. The frequency values, 0, 1, 2, 8 Hz correspond to indices 1, 2, 3, 9.
W6 obtains the FFT of values of W2 at frequencies 0, 1, 2, 8 Hz by using the indices 1, 2, 3, 9. The values compare to the Goertzel result with high precision.
W1: gtri(100, 1/100)^2
W2: mag(fft(w1))
W3: f = {0, 1.6, 2.3, 8.1};mag(goertzeldft(W1, f))
W4: xy(f, W3)
W5: W2;overp(W4);setsym(14, 2);setx(0, 9)
W6: mag(fft(W1, 1024));overp(W4);setsym(14, 2);setx(0, 9)
Similar to above, except the Goertzel DFT in W3 is evaluated at frequencies 0, 1.6, 2.3 and 8.1 Hz. These frequencies are not constant multiples of the 100 sample FFT frequencies.
W4 displays the Goertzel DFT magnitude vs frequency.
W5 compares the full 100 point FFT to the Goertzel result.
W6 compares a higher definition FFT with the Goertzel result.
W1: gsin(1000, 1/1000, 250) + gnorm(1000, 1/1000)
W2: goertzeldft(w1, 240...002..260);2*mag(w0)/length(w1)
W3: spectrum(w1)
W4: spectrum(w1, 500000);semilogy();overp(w2)
W1 contains a noisy 250 Hz sine wave sampled at 1 kHz.
W2 displays the normalized magnitude of the DFT of W1 from 240 to 260 Hz with a frequency spacing of 0.002 Hz.
W3 displays the normalized
DFT of W1 with a frequency spacing of
W4 uses zero padding
to display a finer spaced DFT with a spacing of
The Goertzel DFT of W2 and the full FFT of W4 have identical frequency spacing (0.002 Hz). However, the Goertzel DFT focuses only on the 240 Hz to 260 Hz range, producing 10,001 samples, while the full FFT covers 0 Hz to 500 Hz, requiring a total of 250,001 samples to maintain the same resolution within the Goertzel’s frequency range.
The Goertzel algorithm is a technique used for the efficient calculation of individual terms of the Discrete Fourier Transform (DFT). Unlike the FFT, which computes all DFT coefficients, the Goertzel algorithm is particularly useful when a specific frequency or a small set of frequencies are required within a series.
The algorithm computes the DFT samples in the form of a two stage cascaded digital filter where the first stage is a direct form IIR filter and the second stage is an FIR filter.
The output frequencies, freq, do not need to be an integer multiple of the full FFT frequencies.
Oppenheim and Schafer
Discrete-Time Signal Processing, Second Edition
Prentice Hall, 1999