Re: phase of fft on matlab



On Mar 17, 1:44 pm, "mariauld" <marius.pel...@xxxxxxxxxxxxxxxxxx>
wrote:
Hi,

first I'd like to thank you all, Bharat, Kamar, Manolis, Dirk, for your
useful help.
Bharat, your idea of cleaning up the numbers close to zero
helped me to avoid noise effects.
I associated this with the idea of Dirk, using fftshift on vector x.
This leads me to good results:

x1 = -0.6:0.001:0.6;
x = ifftshift(x1);
testx = exp(-((50*x).^2));

tftestxinit = fft(testx);
tftestx = fftshift(tftestxinit);

%---------------------------- code modification start

hz = tftestx;

hzr = real(tftestx);
hzi = imag(tftestx);
index = find(abs(hzr) < 1e-10);
hzr(index) = 0;
index = find(abs(hzi) < 1e-10);
hzi(index) = 0;
tftestm = complex(hzr, hzi);

%---------------------------------- code modification ended

abstftestx = abs(tftestm);
angletftestx = angle(tftestm);

f = 1000*(-600:600)/1201;
figure;plot(f,abstftestx)
title('absolute frequency content of testx')
xlabel('f (1/m)')
ylabel('magnitude of the dft')

figure;plot(f,angletftestx)
title('angular frequency content of testx')
xlabel('f (1/m)')
ylabel('phase of the dft')

Thank you all again

I just realized I don't have time tonight. So here are a few things to
consider:

1)you need to take off one sample to make the FFT input "implied
symmetric" if you are going to ideally expect all real FFT output
results.

2)real output results does not have to mean zero phase. If the number
is positive, then it has zero phase. If the number is negative, the
phase is +-pi, whatever your phase function returns for a negative
number.

3)what you are taking the FFT of is a rectangularly windowed
gaussian. The output of the FFT will be close to gaussian over some
range, but not gaussian.

4)the FFT output magnitude decreases at a very fast rate. If you plot
it on a log scale you will see that at some point the magnitude
noticably ceases to be gaussian.

5)the phase is only close to what you expect for gaussian when the
magnitude is close to gaussian.

6)setting the small values to zero gives a phase of 0 in the matlab
atan2 function. This generally is not a correct thing to do since you
rarely have reason to believe the phase should be zero. However, it
may be a useable thing to do.

7)with the gaussian pulse generated centered in the FFT window, but
operated on by fftshift prior to the fft the phases are approx 0 where
the output magnitude is close to gaussian.

8)with the gaussian pulse in the center of the FFT window, the phases
where the magnitude is close to gaussian generally alternate between
approx 0 and +-pi (one or both), where the output magnitude is close
to gaussian. The phases are not all 0.

9) When the fft output magnitude ceases to be close to gaussian
(flattens out on log scale), the phase is pretty random, not always 0.

Hope that helps,

Dirk
.



Relevant Pages

  • Re: FFT test with few kbits
    ... ]>>> average to N/2 while the rest should average to zero. ... ]>>> able to test that they have the same gaussian distribution as the ... ]> output of the DFT is a weighted sum of N random inputs. ... ]> Gaussian distributed. ...
    (sci.crypt)
  • Re: Scaling the fft
    ... I am trying to perform an fft on some data but have been ... having trouble with the scaling of the frequency axis. ... resulting gaussian on transform is expected to have width ... Again, the troubleshooting is ...
    (comp.soft-sys.matlab)
  • Re: fft gaussian
    ... samples in frequency domain and the position of the gaussian ... my question is about the use of fft for a time domain ... %plot(xp,Yfix) % The 'not yet normalized' plot. ...
    (comp.soft-sys.matlab)
  • Re: Fast 2d convolution using FFTW
    ... if you know that the FT of a gaussian is a gaussian, ... just multiply the fft of image with invented gaussian in fourier domain, ... all you are doing is lo pass filtering - so you are only selecting the low ... also zero padding always stinks - you may have to smooth abrupt transistion ...
    (comp.dsp)
  • Re: spectral peak-estimation by cross-correlation
    ... The Gaussian window was chosen to: ... the amplitudes of two non-peak bins. ... an fft size of 64 .. ...
    (comp.dsp)

Loading