How do I plot an FFT of a large data set?

17 views (last 30 days)
I have a very large data set that I am trying to use to plot a FFT. The sampling frequency is 20000 and there are 555201 data points. My code is not giving me an accurate graph for figure 2, the plot of the FFT.
Here is my code:
filename = 'Sample192.xlsx';
T = readtable(filename);
x = T{1:555201,1};
y = T{1:555201,2};
%
figure(1)
plot(x,y);
%
Y = fft(y);
Fs = 20000;
f = (0:length(Y)-1)*(Fs/length(Y));
figure(2)
plot(f,abs(Y))
  3 Comments
Mathieu NOE
Mathieu NOE on 9 Dec 2021
hello
can you share the data file as well ?
tx
Angelica Black
Angelica Black on 9 Dec 2021
The data file is too large for me to upload but I can probably attach a snippet of the data if that'll work.

Sign in to comment.

Accepted Answer

David Goodmanson
David Goodmanson on 10 Dec 2021
Edited: David Goodmanson on 10 Dec 2021
Hi Angelica,
One possible reason is that the data has a DC offset, i.e. its mean is not zero. What can happen is that the DC offset, which is the f=0 point in the resulting transform, is much, much larger that any other point in the fft, so all you see is a peak at f = 0. For a signal S, If you take away the mean with S = S - mean(S) and then do the transform, you may well do better. Or you could do the equivalent by taking the existing transform (let's say the fft output is Y) and zero out the first point (which corresponds to f=0 if you have not used fftshift) with Y(1) = 0 and see what that looks like on a plot.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!