MATLAB Answers

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

99 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
plot(Fv, abs(FTvr(Iv))*2)
You can use the File Exchange contribution NUFFT, NFFT, USFFT (link) if you want, but you probably don’t need it here.
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)


Community Treasure Hunt

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

Start Hunting!