0
\$\begingroup\$

I'm trying to plot the phase of Fourier transform of the function below:

\begin{gather*} x[n] = 2e^{-0.9|n|} \: \: n \in [-5,5]\\ x[n] = 0 \:\: n \notin [-5,5] \end{gather*}

which is equal to the function below:

\begin{gather*} x[n] = 2e^{-0.9|n|} \times \mathrm{rect}(5) \end{gather*}

so I calculated the Fourier transform like below:

\begin{gather*} x[n] = 2e^{-0.9|n|} \times \mathrm{rect}(5)\\ y[n] = \alpha^{|n|} \:\: |\alpha |< 1 \\ Y[e^{jw}] = \frac{1-\alpha^2}{1+\alpha^2-2\alpha \cos(w)}\\ \longrightarrow x[n] = 2(\frac{1}{e^{0.9}})^{|n|} \longrightarrow\\ X[e^{jw}] = \frac{1}{2\pi} 2 \frac{1-(\frac{1}{e^{0.9}})^2}{1+(\frac{1}{e^{0.9}})^2-2(\frac{1}{e^{0.9}}) \cos(w)} * \frac{\sin\left(w(\frac{1}{2}+5\right)}{\sin\left(\frac{w}{2}\right)}\\ X[e^{jw}] = \frac{1}{\pi} \frac{1-(\frac{1}{e^{0.9}})^2}{1+(\frac{1}{e^{0.9}})^2-2(\frac{1}{e^{0.9}}) \cos(w)} * \frac{\sin\left(\frac{11w}{2}\right)}{\sin\left(\frac{w}{2}\right)} \end{gather*}

in which * represents a convolution. As you see I shouldn't get linear phase because both sides of the convolution don't even have phase. However, when I draw it in Matlab I get linear phase and I'm stuck. I don't know why.

x = @(t) 2*exp(-0.9 .* abs(t)).* ((t<= 5) & (t>= -5));
time_step =1;
t = -5:time_step:5;
yfft = fftshift(fft(x(t)));
f = linspace(-pi, pi, numel(yfft));
plot(f,unwrap(angle(yfft)));
xlim([-pi,pi]);

I also added N number to FFT so it pads the function with zero, but the result is same as before.

enter image description here

The plot is like above and phase is linear which it shouldn't be.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I think I have an idea what your problem is likely to be. I assume that you were expecting zero phase as your function is a real function of frequency (no imaginary components).

The difficult with this is your time vector starts at index 1 with the value of -5 and increases to +5. By convention, the FFT in MATLAB assumes the fist index of the input is time value 0. The actual time 0 value in your example occurs at same later sample. This looks like a delay to the MATLAB FFT and a delay in time is a linear phase in frequency.

There are a couple of options to deal with this that I can immediately think of.

  1. Compensate as you know the erroneous phase based on the location of you function's zero time by multiplying yfft by the appropriate exp(1j*2*pi*n*delay) factor.
  2. Adjust how you set up the input to the FFT such that the zero time sample of your function is at the first sample of the vector and all of the negative time offsets are not at the end of the vector having "wrapped around." One of the easiest ways to implement this is to replace fftshift(fft(x(t))) with fftshift(fft(circshift(x(t),-5))), where the -5 is the number of samples to left shift to move your zero delay sample to the 1st position of the vector input to the FFT.
\$\endgroup\$

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.