MATLAB Answers

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

172 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


Sign in to comment.

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.


Show 1 older comment
Star Strider
Star Strider on 12 Nov 2017
My pleasure.
The fft function calculates the two-sided Fourier transform, and the energy of the signal is divided evenly between the two halves. Here we are looking at the one-sided Fourier transform, so in order to represent the amplitudes correctly, it is necessary to multiply the amplitudes by 2.
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?
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)