how to obtain the frequency when doing the fourier trasform

2 ビュー (過去 30 日間)
giacomo labbri
giacomo labbri 2020 年 7 月 2 日
コメント済み: Star Strider 2020 年 7 月 3 日
Hi,
I am applying the fast fourier trasform to a timeseries. When I plot the transform (or better its absolute value) I would like to have on the x axis a range of frequency but I am not sure how to calculate that.
I am working with data that are each minute and are registered in a timetable.
Thanks in advance,
Giacomo

採用された回答

Star Strider
Star Strider 2020 年 7 月 2 日
Assuming that the data are regularly sampled, so that the sampling intervals are the same for all of them, I usually do something like this:
y = ...; % Signal (Vector Or Matrix)
t = ...; % Time Vector
Fs = 1/mean(diff(t)); % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
ym = y - mean(y); % Subtract Column Means From All Columns (Eliminates D-C Offset Effect)
L = numel(t); % Signal Lengths
FTy = fft(ym)/L; % Fourier Transform (Scaled For Length)
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTy(Iv,:))*2)
grid
This calculates and plots a one-sided Fourier transform. You will need to supply ‘t’ and ‘y’. The code should be reasonably robust.
.
  2 件のコメント
giacomo labbri
giacomo labbri 2020 年 7 月 3 日
Thanks for your detailed answer!
Star Strider
Star Strider 2020 年 7 月 3 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by