0
$\begingroup$

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

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?

$\endgroup$
10
  • $\begingroup$ 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. $\endgroup$ – AnonSubmitter85 Feb 4 '14 at 18:14
  • $\begingroup$ @AnonSubmitter85 I did an interpolation first, to obtain a uniformly sampled data $\endgroup$ – user2536125 Feb 4 '14 at 18:25
  • $\begingroup$ 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. $\endgroup$ – AnonSubmitter85 Feb 5 '14 at 0:28
  • $\begingroup$ Migrating by OP request. $\endgroup$ – Willie Wong Feb 5 '14 at 11:49
  • $\begingroup$ Actually, interpolation should be useful. I don't know what the question actually is. $\endgroup$ – user7358 Feb 5 '14 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.