Goertzel Algorithm for calculating amplitude and angle
Mostrar comentarios más antiguos
Hello everybody!
I have written a script that describes Goertzel Algorithm. The script is given below. The algorithm calculates correct real part but incorrect imaginary part of original signal. So how to receive the correct imaginary part?
Sampling frequency (N) & nominal frequency (f) with simulation interval (t) are given as:
N = 80; % points/period
f = 50; % Hz
t = 0.02; % s
Time array is:
TimeArray = 0:1/f/N:t;
Original signal array is equal:
x = cos(2*pi*f*TimeArray);
The first part of Goertzel Algorithm is given below.
% W - z^-1
% H(z) = ---------------------------
% 1 - alpha * z^-1 + z^-2
%
% W = W_N^(-k) = exp(2i*pi*k/N).
% alpha = 2*cos(2*pi*k/N).
k = 50; % Spectral sample number
om = 2*pi*k/N;
w = exp(-1i*om);
%alpha
alpha = 2*cos(om);
s1 = 0; s2 = 0;
for h7 = 1:length(x)
s0 = alpha * s1 - s2 + x (h7);
s2 = s1;
s1 = s0;
end
The second part of Goertzel Algorithm is Xk. Xk is the algorithm output. Here Xk gives out complex number. However Xk gives me correct real and incorrect imaginary of complex number.
Xk = s1 - w * s2;
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Spectral Analysis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!