After an FFT of a signal is done, it is plotted as in the image below, with the original signal is on the first subplot.

No Ballast

Using the magnitude and phase data of each frequency, it's reconstructed, and the produced signal is as the image below.

No Ballast Reconstruction

The reconstructed is signal is good except it's shifted 4 milliseconds earlier from the the original signal. I also has done this with another signal, but this 4 milliseconds shift is there too. Why does this happen?

Additional question: I used this for harmonic analysis of 50 Hz fundamental frequency (electric power system frequency). I had a slightly hard time determining which frequency of each harmonic (50*n Hz) frequency to use because, from the FFT result, the phase angle is θ at (50*n∓0.001) Hz but suddenly becomes θ±180° at (50*n±0.001) Hz. For example, at 149.999Hz the phase angle is 223.3° but at 150.001Hz the phase angle is suddenly 403.3°. Is this hard time determining which angle of each frequency to use for reconstruction, normal?

By the way, this is the Matlab code I use to do the FFT and the plotting.

Fs = 1/(8e-6);                % Sampling frequency
T = 1/Fs;                     % Sample time
L = 2^21;                     % Length of signal
t = (0:L-1)*T;                % Time vector

SampleNoBallast;              % The original signal

NFFT = 2^nextpow2(L);         % Next power of 2 from length of y
Y = fft(y,NFFT)/L;            % The Fast Fourier Transform producing FFT complex
f = Fs/2*linspace(0,1,NFFT/2+1);     % Frequencies to plot
P = rad2deg(unwrap(angle(Y)));       % Phase degrees from FFT complex

% Plotting the original signal
subplot(3,1,1); plot(t(1:12500),y(1:12500))
title('Arus Masukan LED T8 Opple 18 W tanpa Ballast')
ylabel('arus (mA)')
xlabel('waktu (s)')
grid on
% Plot single-sided amplitude spectrum.

% Plotting the magnitude of each frequency
subplot(3,1,2); plot(f(1:17000),2*abs(Y(1:17000))) 
title('Hasil FFT')
xlabel('Frekuensi (Hz)')
ylabel('Amplitudo (mA)')

% Plotting the phase of each frequency    
subplot(3,1,3); plot(f(1:17000),P(1:17000)) 
title('Sudut Komponen Harmonik')
xlabel('Frekuensi (Hz)')
ylabel('Sudut (derajat)')
  • 2
    $\begingroup$ Welcome to DSP.SE! How did you generate the reconstructed signal? If it was just using ifft then there is something very wrong. If you're doing some modification of the original FFT data or using something other than ifft to reconstruct it, then we need to see that to be able to answer your question. $\endgroup$
    – Peter K.
    Mar 18, 2016 at 18:53
  • $\begingroup$ See my answer here about why your phase angle flips at slightly different frequencies, and, thus, the proper way to measure phase of arbitrary frequency spectrum: dsp.stackexchange.com/questions/29509/… $\endgroup$
    – hotpaw2
    Mar 18, 2016 at 19:32
  • $\begingroup$ Thank you for the welcome. I reconstruct the signal using an electronic simulation program, LTSpice, by putting together 10 current sources of each frequency (50 Hz, 150 Hz, 250 Hz, ..., 950 Hz). The original FFT data consists of 12500 points, but to give more resolution to the FFT result, I duplicate it 168 times to make it slightly more than 2^21. $\endgroup$ Mar 19, 2016 at 0:20
  • $\begingroup$ I tried using ifft and the result is perfect, but if I tried to use LTSpice for the reconstruction, there's the phase shift. $\endgroup$ Mar 19, 2016 at 2:03

1 Answer 1


The shift is due to using an FFT with a different length than the length of the data, and likely using a non-symmetric arrangement of zero-padding to increase that original length to the zero-padded length.

Non-symmetric zero-padding rotates the phase results of an FFT, spiraling across result bins.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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