fftshift/ifftshift

大兔子大兔子 提交于 2019-12-13 12:30:09

问题


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)...



来源:https://stackoverflow.com/questions/15100195/fftshift-ifftshift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!