Borrar filtros
Borrar filtros

How do i calculate the frequency of signal with low sampling rate

3 visualizaciones (últimos 30 días)
Matthias
Matthias el 26 de Mayo de 2014
Comentada: Star Strider el 27 de Mayo de 2014
I've got a sinusoidal signal with a low sampling rate:
x = 0:0.2*pi:6*pi;
y = sin(x) -0.25 + 0.5* rand(size(x));
Is the a fast and accurate way to determine the frequency of this signal? The only way I can think of is to make a fit, but with 4 parameters:
A*sin(B *x + C) + D
it is quite hard to make a good guess and therefore have a fast program. Are there other methods to determine the frequency, like e.g. pulse counting?
  2 comentarios
Matthias
Matthias el 27 de Mayo de 2014
Isn't the spectral resolution of the FFT not much worse than the spectral resolution of a simple sin fit?

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 26 de Mayo de 2014
Plotting it, the sampling rate is significantly higher than the Nyquist frequency, so the FFT will be reasonably accurate:
x = 0:0.2*pi:6*pi;
t = x/(2*pi); % Time vector (added)
y = sin(x) -0.25 + 0.5* rand(size(x));
figure(1)
plot(x, y, '.-')
grid
fty = fft(y);
afty = abs(fty);
fvrs = [0:fix(size(fty,2)/2)]*0.2*pi; % Frequency rad/t
fvHz = [0:fix(size(fty,2)/2)]*0.1; % Frequency Hz
lenv = 1:size(fvHz,2);
figure(2)
plot(fvHz, afty(lenv))
grid
I display the fft here in cycles/time (assume Hz). Substitute the frequency vector ‘fvrs’ in the plot to see it in radians/time. The frequency is about 0.25 Hz.
It’s not difficult to do a nonlinear regression using fminsearch or any of the other nonlinear regression routines. You can express your function as an ‘anonymous function’ and use it to fit your data. The function name ‘fitsin’ is already a function handle, so you don’t have to use the initial ‘@’ when referring to it in your code or as an argument to the fitting function.
fitsin = @(b,x) b(1).*sin(b(2).*x + b(3)) + b(4);
Use the frequency data from the fft for your initial estimate for b(2), and define the others as 1, unless you already have an idea of their values.
  2 comentarios
Matthias
Matthias el 27 de Mayo de 2014
I already have a good idea what the frequency is going to be, I just want to characterize the deviation from main supposed frequency. So I could skip the FFT part and just use a fit, which is my current method.
Star Strider
Star Strider el 27 de Mayo de 2014
I’ve fit periodic functions using regression functions similar to ‘fitsin’ with the various nonlinear solvers and fminsearch (with an OLS objective function). The advantage of starting with the FFT is that it gives you a reliable estimate of the predominant frequency as one of your initial parameter estimates. I’ve had nonlinear solvers fit harmonics instead, the reason I suggested the FFT.

Iniciar sesión para comentar.

Categorías

Más información sobre Spectral Estimation en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by