Documentation Center

  • Trials
  • Product Updates

goertzel

Discrete Fourier transform with second-order Goertzel algorithm

Syntax

dft_data = goertzel(data)
dft_data = goertzel(data,freq_indices)
dft_data = goertzel(data,freq_indices,dim)

Description

dft_data = goertzel(data) returns the discrete Fourier transform (DFT) of the input data data using a second-order Goertzel algorithm. If data is a matrix, goertzel computes the DFT of each column separately.

dft_data = goertzel(data,freq_indices) returns the DFT for the frequency indices freq_indices.

dft_data = goertzel(data,freq_indices,dim) computes the DFT of the matrix data along the dimension dim.

Examples

Estimate the frequency of the two tones generated by pressing the 1 button on a telephone keypad:

f=[697 770 852 941 1209 1336 1477];
% frequencies for numbers 0:9 on keypad
Fs = 8000; %sampling frequency
N = 205;	%Number of points
% Tones generated by a "1": 697 and 1209 Hz 
data = sum(sin(2*pi*[697;1209]*(0:N-1)/Fs));
% Indices of the DFT for the frequencies f 
freq_indices = round(f/Fs*N)+1;   
%Compute DFT using Goertzel algorithm
dft_data = goertzel(data,freq_indices); 
%Plot the DFT magnitudes
stem(f,abs(dft_data)); 
set(gca,'xtick',f); xlabel('Hz');
ylabel('Magnitude');

Alternatives

You can also compute the DFT with:

  • fft less efficient than the Goertzel algorithm when you only need the DFT at a few frequencies.

  • czt the chirp z-transform. czt calculates the z-transform of an input on a circular or spiral contour and includes the DFT as a special case.

More About

expand all

Algorithms

The Goertzel algorithm implements the DFT as a recursive difference equation. To establish this difference equation, express the DFT as the convolution of an N-point input x(n) with the impulse response , where and u(n) is the unit step sequence.

The z-transform of the impulse response is:

The direct form II implementation is:

References

Proakis, J.G. and D.G. Manolakis. Digital Signal Processing: Principles, Algorithms, and Applications, Upper Saddle River, NJ: Prentice Hall, 1996, pp. 480–481.

Was this topic helpful?