how to obtain the frequency when doing the fourier trasform

1 次查看(过去 30 天)
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.
.

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by