Either ignore the first output bin, or else subtract off the mean before further processing.
How to find the signal frequency?
3 次查看(过去 30 天)
显示 更早的评论
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!