2
votes

I am performing FFT with Matlab on the Green function, and I get a strange result that I can't explain.

With the definition of Green function (G(r)=-1/(4*pi*r) and taking G(0)=1 to avoid divergence, I am doing two different samplings, one defined on the interval [-128:1:127] and the other on [0:1:255].

For plotting, I am using fftshift Matlab function. My issue is that I get for the first interval ([-128:1:127]) an unexpected FFT like it is showed on the following figure : enter image description here

Here is the code snippet for this result :

% FFT with Green Function on -128:1:127
t=-128:1:127;
y = 1./(4*pi*sqrt(t.^2));
y(129) = 1.0;        %%% to avoid divergence with y=1/(4*pi*0)=inf %%%
title('Plot of 1D Green function'); 
z=fftshift(fft(y));
figure(1);
plot(real(z)); %%%% Original signal is real and symetric ==> So its FFT has to be real; I only select the real part for killing small imaginary parts and having a nice plot %%%%
%plot(abs(z));
title('Plot of 1D FFT Green function on -128:1:127');

Now, I take the second interval [0:1:255] and apply a FFT. Here's the figure :

enter image description here

Below the code snippet which produces this figure :

% FFT with Green Function on 0:1:255
t=0:255;
y = 1./(4*pi*t);
y(1) = 1.0;      %%% to avoid divergence with y=1/(4*pi*0)=inf %%%
figure(3);
plot(y);
title('Plot of 1D Green function on 0:1:255'); 

z=fftshift(fft(y));
figure(4);
plot(real(z));
%plot(abs(z));
title('Plot of 1D FFT Green function on 0:1:255');

I don't understand this result because in this second case, the signal is real but not symetric : so FFT has also imaginary parts (that we can't neglect) and then we have only the Hermitian symetry ( X(-f)=[X(f)]^* ).

The second figure is the one that I expect, i.e a curve in the form TF(G)(k) = -1/k^{2} but I can't explain this result. knowing I take only the real part, this is still more troublesome.

I would have prefered to get this second figure for the first case (the first code snippet) because we have a real and axe ( in x = 0 ) symmetry for Green function.

How can we interpret this difference?

I make you notice that if I put plot(abs(z)) instead of plot(z) in the first code snippet, I get the same curve that in case 2, i.e the expected curve: what does it mean?

What is the reason for the discrepancy between these 2 results? And how can I find the good curve with first code snippet?

1

1 Answers

2
votes

The DFT (or FFT) considers the time origin is the first input sample. Your first snippet is the same as the second except that

  1. There's a time displacement.
  2. One half of the time-domain spike is missing in the second snippet.

The time displacement corresponds to multiplying by an oscillatory term in the frequency axis, which is what you get in the first case.

If you plot both signals y you'll see that in the second case about one half of the signal is missing. The left part of the spike, which should appear at about time 250 in the second case, is not there; whereas in the first case it is. That's also introducing some differences, in particular the amplitude of the spectrum is smaller in the second case; and the spectrum shape is probably affected too.

To obtain the "good" spectrum with the first snippet (which is the one that correctly defines both tails of the spike in time domain), just apply fftshift in the time domain. That will give a signal centered at the first time sample as it should, and with the two halves of the spike.

% FFT with Green Function on -128:1:127
t=-128:1:127;
y = 1./(4*pi*sqrt(t.^2));
y(129) = 1.0;        %%% to avoid divergence with y=1/(4*pi*0)=inf %%%
y = fftshift(y); %// THIS LINE ADDED
title('Plot of 1D Green function'); 
z=fftshift(fft(y));
figure(1);
plot(real(z)); %%%% Original signal is real and symetric ==> So its FFT has to be real; I
% only select the real part for killing small imaginary parts and having a nice plot %%%%
%plot(abs(z));
title('Plot of 1D FFT Green function on -128:1:127');

enter image description here