フィルターのクリア

How to find the signal frequency?

5 ビュー (過去 30 日間)
Miguel Minga
Miguel Minga 2021 年 3 月 7 日
コメント済み: Walter Roberson 2021 年 3 月 7 日
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 件のコメント
Walter Roberson
Walter Roberson 2021 年 3 月 7 日
Either ignore the first output bin, or else subtract off the mean before further processing.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by