1
$\begingroup$

I am going to plot the phase spectrum of a zero-phase ricker wavelet. I calculate the fft of the wavelet and use the phase or angle to calculate the phase spectrum but the result is not zero!

I use the following code:

Fs = 250;
t = 0:1/Fs:0.5*(Fs-1)/Fs;
f1 = 30;
w = (1-2*pi^2*f1^2.*t.^2) .* exp(-(pi*f1.*t).^2);
X = fft(w);
plot(angle(X));
$\endgroup$

1 Answer 1

3
$\begingroup$

Your vector w is not symmetric, so don't expect a zero-phase FFT result. Just do plot(t,w) to see what the FFT sees as its input. The reason is that you computed w only for positive t. What you need to do is the following:

  • Choose an odd number of equidistant time domain points $2N+1$
  • Compute N+1 points of the Ricker wavelet for non-negative $t$ starting with $t_0=0$
  • Since the wavelet is symmetric, the $N$ points for $t<0$ are identical to the $N$ points for $t>0$
  • append these values for negative $t$ at the end of the time domain vector to be transformed: w = [r_0,r_1,...,r_N,r_N,r_{N-1},...,r_1]. The reason for doing this is that the DFT/FFT assumes the first vector entry to be the value for $t=0$. Appending the values for negative $t$ at the end simply reflects the implied periodicity of all signals transformed by the DFT.

The result will be a real-valued FFT up to numerical errors.

In Matlab this would look like this:

Fs = 250;
N = 50;
t = (0:50)/Fs;
f1 = 30;
w = (1-2*pi^2*f1^2.*t.^2) .* exp(-(pi*f1.*t).^2);
w = [w, w(N+1:-1:2)];
X = fft(w);
max(abs(imag(X)))     % 2.2682e-16 on my machine
$\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.