# Fast Fourrier Transform of real measurements in Matlab

I am trying to perform the fast fourrier transform to non uniformly sampled data . The output is in the following image

It was obtained using the following code in MATLAB

%% x is the sampled signal
%% t is the sampling instances
L=size(x,1);
t_new = linspace(t(1),t(end),L);

% Performing interpolation to obtain a uniformly sampled signal
x_new_cubic = interp1(t,x,t_new,'cubic');
x_new_pchip =interp1(t,x,t_new,'pchip');
x_new_spline = interp1(t,x,t_new,'spline');

NFFT = 2^nextpow2(L);
X = fft(x_new_cubic,NFFT)/L;
F=1000*linspace(0,1,NFFT/2+1);

figure;

subplot(121);
plot(F,20*log10(abs(X(1:NFFT/2+1))));
xlabel('Frequency[Hz]');
ylabel('|X|[dB]');
w =  hamming(L,'periodic');
x_win = w.*x_new_cubic(1:L)';
X_win = fft(x_win,NFFT)/L;

subplot(122);
plot(F,20*log10(abs(X_win(1:NFFT/2+1))));
xlabel('Frequency[Hz]');
ylabel('|X|[dB]');
title('Hamming Window')


It seems that I can't trust such result, but I am not sure too. Can any one give me some advice?

• Your code is unreadable in its current form, but I can tell you that the fft() function assumes that its input is evenly spaced. I don't know what you'll get if it's not, but it won't be the DFT. – AnonSubmitter85 Feb 4 '14 at 18:14
• @AnonSubmitter85 I did an interpolation first, to obtain a uniformly sampled data – user2536125 Feb 4 '14 at 18:25
• You need to use a resampling method that includes filtering. You can't just interpolate with splines and and the like and expect the spectrum to be as it should. Also, you'll get more visibility from the right people if you add the signal-processing tag. The dsp stackexchange site is another option for help on things like this. – AnonSubmitter85 Feb 5 '14 at 0:28
• Migrating by OP request. – Willie Wong Feb 5 '14 at 11:49
• Actually, interpolation should be useful. I don't know what the question actually is. – user7358 Feb 5 '14 at 12:01