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 :
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 :
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?