MATLAB: How to find FFT of a non-uniformly sampled data

fft

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

Best Answer

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.
Related Question