How to find the signal frequency?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all, how can I find the signal frequency?
I'm using this code:
Nsamps = 27377;
fsamp = 60; %Freq device freematics One+:50-60[Hz]
Tsamp = 1/fsamp;
t = (0:Nsamps-1)*Tsamp;
x = Altf; %input signal
% Plot time-domain signal
subplot(2,1,1);
plot(t, x);
ylabel('Amplitude'); xlabel('Time (secs)');
% axis tight;
title('Input signal');
% Choose FFT size and calculate spectrum
Nfft =1024; %1024
[Pxx,f] = pwelch(x,gausswin(Nfft),Nfft/2,Nfft,fsamp);
% Plot frequency spectrum
subplot(2,1,2);
plot(f,Pxx);
ylabel('PSD');
xlabel('Frequency (Hz)');
grid on;
% Get frequency estimate (spectral peak)
[~,loc] = max(Pxx);
FREQ_ESTIMATE = f(loc)
title(['Frequency estimate = ',num2str(FREQ_ESTIMATE),' Hz']);
When running the program I get a frequency of zero

1 comentario
Walter Roberson
el 7 de Mzo. de 2021
Either ignore the first output bin, or else subtract off the mean before further processing.
Respuestas (0)
Ver también
Categorías
Más información sobre Spectral Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!