# Phase is not linear in frequency domain after delay in time domain

When impulse response is symmetric around sample zero phase entirely zero.

in = 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 0 , 0 , 0 -> This gives zero phase result

As I know if I apply a delay in time domain this should result a linear phase in frequency domain. So if I delay my previous vector by one;

in = 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 0 , 0 -> This should give linear phase responce

const int N = 11;

// in = 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 0 , 0
std::vector< std::complex<double> > in (N);
std::vector< std::complex<double> > out (N);
std::vector< std::complex<double> > polarOut (N);

auto middleElem = in.begin() + in.size()/2;
//std::fill( middleElem - 1, middleElem + 3, 1); //zero phase
std::fill( middleElem, middleElem + 4, 1);

fftw_plan my_plan  = fftw_plan_dft_1d(N, reinterpret_cast<fftw_complex*>(&in[0]),
reinterpret_cast<fftw_complex*>(&out[0]), FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(my_plan);

std::transform( out.begin(), out.end(), polarOut.begin(),
[]( auto& in ){
return  std::complex<double>( std::abs(in), std::arg(in) );
} );


The result of the fourier transform in polar notation is :

    polarOut    <11 items>  std::vector<std::complex<double>>
[0] (4.000000, 0.000000)    std::complex<double>
[1] (3.228707, 2.570394)    std::complex<double>
[2] (1.397877, -1.142397)   std::complex<double>
[3] (0.372786, -1.713596)   std::complex<double>
[4] (1.088156, 0.856798)    std::complex<double>
[5] (0.546200, -2.855993)   std::complex<double>
[6] (0.546200, 2.855993)    std::complex<double>
[7] (1.088156, -0.856798)   std::complex<double>
[8] (0.372786, 1.713596)    std::complex<double>
[9] (1.397877, 1.142397)    std::complex<double>
[10]    (3.228707, -2.570394)   std::complex<double>


What am I missing here? Why phase responce is not linearly increasing?

• possible duplicate of Phase response of FFT in practice – jojek Feb 25 '15 at 17:20
• The other question also asked by me. My privous question solved thanks to a answer, this problem occurred after delaying the impulse response. This can be a extension to my privious question not a duplicate. – Kadir Erdem Demir Feb 25 '15 at 18:38
• Ya, I think the question is different from the other one, and the answer from Matt is educational. +1 – Peter K. Feb 28 '15 at 19:41

The phase is in fact linear, apart from jumps of $\pi$ at the zeros of the magnitude. There are two reasons why you don't see it:

1. the phase you compute is the principal value, which is in $(-\pi,\pi]$. Note that you can always add or subtract a multiple of $2\pi$ to the phase without changing anything. Removing these artificial jumps due to the principal value is called phase unwrapping.

2. you only compute very few points, and due to point 1 above you just see an erratic behavior.

Solution:

1. compute a more detailed DFT (by zero-padding the original signal)
2. unwrap the phase (if you have Matlab/Octave, there's a command to do that)

Here an example in Matlab/Octave:

x = [0 0 0 0 0 1 1 1 1 0 0];
X = fft(x,512);         % length 512 FFT
ph = arg(X);            % wrapped phase
phu = unwrap(ph);       % unwrapped phase
plot((0:256),phu(1:257)/pi), grid on


• Even people are down voting my question what I learned from your answer makes me happy. – Kadir Erdem Demir Feb 25 '15 at 19:07