How to find FFT of a non-uniformly sampled data?

31 views (last 30 days)
I have a vibration data in time domain and want to convert it to frequency domain.However my data is not uniformly sampled, so I am having trouble applying fast fourier transform to it. I have attached my excel data file.Can you guys please help

Accepted Answer

Star Strider
Star Strider on 9 Nov 2017
Your data are very close to being uniformly sampled. The mean difference in sampling times (sampling interval) is 976.5623e-006, and the standard deviation is 496.2100e-009. You can interpolate them with the Signal Processing Toolbox resample function to be entirely uniformly sampled, then do the Fourier transform:
[D,S,R] = xlsread('vibration.xls');
t = D(:,1);
v = D(:,2);
tstats = [mean(diff(t)) std(diff(t))] % Information Only
tr = linspace(min(t), max(t), length(t)); % Uniformly-Sampled Time Vector
vr = resample(v, tr); % Resampled Signal Vector
L = length(tr); % Signal Length
Ts = mean(diff(tr)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTvr = fft(vr)/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
figure(1)
plot(Fv, abs(FTvr(Iv))*2)
grid
You can use the File Exchange contribution NUFFT, NFFT, USFFT (link) if you want, but you probably don’t need it here.
  4 Comments
Pedro Andres Molina Cabrera
// just a comment to those wondering the same:
The resampling step as written above is not necessary since both time vectors have the same size. Plotting vr and v shows the same data.
Perhaps an interpolation
y = resample(v, t, 1/mean(diff(t)) );
is more appropriate?
Cheers,
Joseph Fox-Rabinovitz
Joseph Fox-Rabinovitz on 30 Apr 2019
Rather than
tr = linspace(...
vr = resample(v, tr);
you probably want to use
[vr, tr] = resample(v, t);

Sign in to comment.

More Answers (0)

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!