Find the nonzero maximum frequency corresponding to FFT graph.

2 ビュー (過去 30 日間)
Zahra
Zahra 2023 年 4 月 27 日
コメント済み: David Goodmanson 2023 年 4 月 28 日
I want to find the maximum corresponding frequency for the ftt graph. The graph shows the maximum frequency at zero frequency, this is not what I want. I am expecting to have a value around 664 Hz.
The codes:
so=dat.data(:,2); %original signal
t=dat.data(:,1); %time
dt=t(2)-t(1);
Fs=1/dt; %sampling frequency
f=linspace(0,Fs,length(t));
%Fourier Transform
SO=fft(so);
SOa=abs(SO);
F_fake=f(find(SOa(1:round(length(SOa)/2))==max(SOa))); % I am getting zero instead of 663.9 Hz.
I want a value which is nonzero. How to eliminate the zero Hz frequency ?
FFT graph.

採用された回答

David Goodmanson
David Goodmanson 2023 年 4 月 27 日
編集済み: David Goodmanson 2023 年 4 月 27 日
Hi Zahra,
the peak at zero frequency is because your signal does not have average value of zero, but has a DC offset. To eliminate the zero freq peak you can remove the offset by subracting the mean off of the signal. So you can use not fft(signal) but rather fft(signal-mean(signal)). (This assumes that the DC offset is not of interest in this case).
  2 件のコメント
Zahra
Zahra 2023 年 4 月 27 日
Thank you. Would you please explain more about what does DC offset mean?
David Goodmanson
David Goodmanson 2023 年 4 月 28 日
DC offset is a bit of a slang term in the sense that it refers to electrical voltage or current signals, not the most general possible signal. Suppose you have a complicated signal and take the fft. The zero frequency term from the fft corresponds to a constant value in the time domain. Now consider a simple example of constant term of value 3 and just one nonzero frequency of amplitude 10. In terms of voltage this is modeled as a 10V cosine signal in series with a 3V battery, 10*cos(2*pi*f) + 3. The cosine term of course has mean value of 0 and the constant term, 3, is called the DC offset.

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

その他の回答 (1 件)

Paul
Paul 2023 年 4 月 27 日
編集済み: Paul 2023 年 4 月 27 日
If the DC offset is of interest (or even if it isn't)
[maxSOa,index] = max(SOa(2:end)); % ignores first point a f=0
F_fake = f(index+1)
This approach will find the the frequency corresponding to the first maximum value in SOa(2:end) should there be multiple occurrences of the maximum value.

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by