1
$\begingroup$

Most fft tutorials use sinusoidal signals for demonstration, which makes the user already know what the fft is supposed to give as an output, but what about real time signals where we don't have any previous knowledge except the sampled data with the following problems:

  • No previous knowledge
  • Variable sampling time
  • Unknown Noise

I have a signal which has the previous characteristics, so I used the following Matlab code to interpolate and select a proper period (visually):

clear all
load('ExperimentData.mat')
close all
% Because the sampling period is not constant, I have first to interpolate the data
Ts=min(diff(t));Fs=1/Ts;
t_new=t(1):Ts:t(end);
x_new=interp1(t,x,t_new);
%% Extracting one period and Applying ZERO PADDING
tStart=0.7086;[~,idxStart]=min(abs(t_new-tStart));
tEnd=0.7686;[~,idxEnd]=min(abs(t_new-tEnd));
x1p=x_new(idxStart:idxEnd);
t1p=t_new(idxStart:idxEnd);
F=figure;plot(t,x,'b');hold on
plot(t_new,x_new,'r:')
plot(t1p,x1p,'.-g');
ylabel('x');xlabel('time[sec]');legend('Original signal','Interpolated Signal','One Period')

The outcome is the following: Time signals

I then applied the FFT once on the complet signal an once on one period with ZERO padding using the following code:

X = fft(x_new-mean(x_new));
N = size(x_new,2);
f=Fs/2 * linspace(0,1,N/2+1);
figure;
AX(1)=subplot(211);semilogx(f,abs(X(1:N/2+1)));ylabel('Magnitude');xlabel('Frequency(Hz)');title('Entire signal Without Zero Padding')
AX(2)=subplot(212);semilogx(f,angle(X(1:N/2+1)));ylabel('Phase');xlabel('Frequency(Hz)')
linkaxes(AX,'x');axis  tight;
%Zero Padding
x_1PZP=[x1p-mean(x1p) zeros(1,100000)];
X_1PZP = fft(x_1PZP);
figure;
AX(1)=subplot(211);semilogx(f,abs(X_1PZP(1:N/2+1)));ylabel('Magnitude');xlabel('Frequency(Hz)');title('One Period with Zero Padding')
AX(2)=subplot(212);semilogx(f,angle(X_1PZP(1:N/2+1)));ylabel('Phase');xlabel('Frequency(Hz)')
linkaxes(AX,'x');axis  tight

The results are: FFT Results

My wonderings are:

  • Does the interpolation of a signal alter the FFT ?
  • From the Time Signal, the FFT on the complet signal is closer to reality. but it still doesn't show all frequencies. Why?
  • I almost can't extract any information fro the phase plot. What am I missing?

The data can be obtained from this link.

$\endgroup$
  • $\begingroup$ Can you share the data? $\endgroup$ – Seth Mar 23 '15 at 22:44
  • $\begingroup$ Yes, please see my edit $\endgroup$ – user2536125 Mar 24 '15 at 5:21
  • $\begingroup$ Can I please ask what sort of information were you expecting to extract from the phase spectrum? $\endgroup$ – A_A Mar 27 '15 at 11:26
  • $\begingroup$ If its not uniformly sampled you need to use a non-uniform transform, although I'm not really sure this question is about that: see cims.nyu.edu/cmcl/nufft/nufft.html $\endgroup$ – Mikhail Mar 27 '15 at 13:52
1
$\begingroup$

"Does the interpolation of a signal alter the FFT?" Yes, it does. The key point is that in a system that uses sampling, you simply do not know what does the signal "do" between two sampling instances. For a high enough sampling frequency Fs, it is just assumed that the corresponding sampling period is high enough to be approximated by a series of sinc pulses. For more information please see: http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem

By using interpolation, you only assume that the signal behaves in a certain way during the time that it is not observed. Therefore, the result of the FFT will be different, even for different interpolation methods.

Furthermore, interpolation has a "natural" smoothing action because all it can do is "degrade" the existing data, it cannot add anything more to it. For more information about this notion, please see the Data Processing Theorem (https://books.google.co.uk/books?id=F4j8EHBKS1IC&lpg=PA313&ots=tHO2C1ZJs1&dq=the%20data%20processing%20theorem&pg=PA313#v=onepage&q&f=false)

This is why, interpolation will tend to represent lower frequencies (for which you have more data anyway, due to the sampling frequency) better.

By the way, 'interp1' by default uses linear interpolation, that is, intermediate values between sampling instances are assumed to lie on a straight line that is defined by the two known points. An alternative to this would be spline interpolation which takes into account the slope by which the interpolated curve should enter and depart from the interpolating area. For more information about this, please see http://en.wikipedia.org/wiki/Cubic_Hermite_spline

(Please also note Trigonometric Interpolation, a technique very closely associated with the Fourier Transform. For more information please see: http://en.wikipedia.org/wiki/Trigonometric_interpolation)

From the Time Signal, the FFT on the complet signal is closer to reality. but it still doesn't show all frequencies. Why?

Because it is not exactly the same signal, as far as the FT is concerned.

A key property of the Discrete Fourier Transform is "Periodicity". According to this, the signal at the input of the Fourier Transform is assumed...periodic. That is, you may be passing a voice recording of "One Two Three" to the FT to recover its harmonic component but the FT assumes that the signal, in reality sounds like "...One Two Three One Two Three One Two Three One Two Three..." extending to infinity both forwards and backwards. For more information about this please see: http://en.wikipedia.org/wiki/Discrete_Fourier_transform (Periodicity property).

The signal that you call "Time Signal", contains a brief period of silence in the beginning and ends abruptly, that is, it would be discontinuous if it were to be a periodic signal. By the way, you may also be interested in the technique of windowing, for more information please see: http://en.wikipedia.org/wiki/Window_function#Symmetry_and_asymmetry

I almost can't extract any information fro the phase plot. What am I missing?

The phase spectrum is simply the angle between the imaginary and real components of the signal spectrum. However, having seen how the imaginary and real components of the FT look like, their phase content is not expected to be a smooth and well behaved function, except perhaps for very simplistic cases.

By the way, you may want to look up the concept of phase unwrapping, to improve your phase plots. For more information, please see https://ccrma.stanford.edu/~jos/fp/Phase_Unwrapping.html

Hope this helps.

$\endgroup$
  • $\begingroup$ Thanks for the detailed answer, as it gives some hints. As you can notice from my post, I have already tried windowing, and the results were not that much better. Maybe because of my bad interpolation. I wonder if there is any criteria to judge the interpolated signal (From a FT point of view)? $\endgroup$ – user2536125 Mar 27 '15 at 12:06
  • $\begingroup$ You are certainly welcome. I cannot see where was windowing applied from your code or original question. If you have your original waveform you can evaluate the error between the interpolated and original. A bit more information about the signal and application would help. I am sorry if this sounds as a complaint but if you felt that the answer helped you, you can at least upvote it. $\endgroup$ – A_A Mar 27 '15 at 12:20
1
$\begingroup$

Using linear interpolation means that you will naturally get very sharp changes in gradient around your original data points. These sharp changes require a greater range of frequency components for their Fourier representation than a smoother version because sinusoids are themselves smooth functions. This leads to more noise in the Fourier transform in terms of both magnitude and phase, hence the 'unexpected' plots.

The single-period analysis is not only less representative of the original data set (it's just a subset), but is also affected more by the non-periodic nature of the data. Performing a Fourier transform on non-periodic data results in spectral leakage, degrading the quality of the output, and the shorter the sample the more spectral leakage you'll see.

Perhaps the reason you're not seeing the 'expected' results even when using the entire data set is that plotting the Fourier coefficients on a linear scale is not the best way to visualize them relative to one another.

A few things I'd suggest trying:

  • Use an interpolation method that gives you smoother data
  • Plot the Fourier coefficients on a logarithmic scale and see if the results match more closely with what you're expecting
  • If after changing the interpolation method you're still seeing a lot of noise (i.e. wide peaks and noise floor), try windowing the entire data set before performing the transform
$\endgroup$
0
$\begingroup$

The interpolation introduces "noise" and alters the measurement. The FFT computation is attempting to fit sinusoids to the "signal" and as result the in accuracies in the time domain are propagating into ALL the sinusoids of the FFT.

The interpolation process might "zero" some of the frequencies. Particularly, interpolation could be made for the lower frequencies and in some cases emphasize lower frequencies. I assume that your interpolation reduced higher frequencies, though you did not mention it.

The phase is impacted more and as result the calculated phase is farther removed from the actual one.

$\endgroup$
  • $\begingroup$ What do you mean by Particularly, interpolation could be made for the lower frequencies and in some cases emphasize lower frequencies. ? I simply used the interp1(x,y,Xi) command from Matlab for the interpolation $\endgroup$ – user2536125 Mar 23 '15 at 5:00
  • $\begingroup$ The interpolation in the time domain could be very sensitive to the noise (in some cases it may amplify the noise in the high frequencies). It has less impact on the lower frequencies. I am not familiar with the Matlab functions. $\endgroup$ – Moti Mar 23 '15 at 15:07
  • $\begingroup$ Can you please explain how does that happen? If i understand, the interpolation may amplify the high frequencies if we are adding sort of stairs between the samples, but with a linear interpolation, this is not supposed to happen $\endgroup$ – user2536125 Mar 24 '15 at 5:36
  • $\begingroup$ There is the impact of the noise that causes the introduction of what you call steps (or deltas) and those "add" power into frequency bins that are not occupied by the original signal. $\endgroup$ – Moti Mar 24 '15 at 5:40
  • $\begingroup$ And what kind of interpolation would you suggest? linear, spline...etc? $\endgroup$ – user2536125 Mar 24 '15 at 6:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.