fftshift/ifftshift

2019-05-15 08:18发布

问题:

Please, see the the description of both fftshift and ifftshift. I would like to understand how to call the above two functions in relationship with fft and fftn in Matlab.

Let say that my signal has a certain frequency content; now, the frequency array can generally be stored as:

f = (-N/2:N/2-1)*df;

f = (1:N)*(df/2);

f = [(0:N/2-1) (-N/2:-1)];

What is the best way to call fft, coupled with fftshift and ifftshift, for the 3 study cases early mentioned?

What is the effect on the standard deviation of the signal of calling the sequence of commands or the wrong one?

回答1:

The result of fft is (in your notation) indices (0:N-1). fftshift simply converts that to [(N/2:N-1) (0:(N/2-1))].* ifftshift simply restores the original indexing.

As this is simply reordering samples, it does nothing to the standard deviation.


* Note that due to periodicity, sample k is equivalent to sample k+N, or k-N, etc.



回答2:

Matlab documentation is just killing about it. But experiments show that

ifftshift([1 2 3 4 5])

ans =

 3     4     5     1     2

fftshift([1 2 3 4 5])

ans =

 4     5     1     2     3

It is just swapping around the magic DFT position [N/2]. FFT implemented in matlab use usual indexing (0:N-1). As I understand this is extra functions to prepare your input to DFT if your setup is dicrete function not in (0:N-1)...