필터 지우기
필터 지우기

What's the purpose of doing fftshift twice?

조회 수: 60 (최근 30일)
Mark Golberg
Mark Golberg 2016년 6월 9일
댓글: Jan 2017년 2월 24일
Hello,
I have a signal in time domain (x).
Can someone please explain the difference between:
y1 = fftshift(fft(x));
y2 = fftshift(fft(fftshift(x)));
As I understood y2 is the better/more common approach. Why???
Thank you!!
  댓글 수: 4
Walter Roberson
Walter Roberson 2016년 6월 9일
y2 assumes that time 0 is in the middle of the array and shifts it to the beginning of the array, as needed for fft. That is possible but it is not common: people seldom want to deal with negative times. Having centered data is more common for some other kinds of data.
Adam
Adam 2016년 6월 9일
y2 does not really make sense. fftshift is a frequency domain operation, applying it in the time domain does not make sense. See Walter's answer for more detail.

댓글을 달려면 로그인하십시오.

채택된 답변

John BG
John BG 2016년 6월 9일
Mark
command fftshift is used to visualise the FFT within [-Fs/2 Fs/2] instead of [0 Fs] that is the interval that the FFT takes as default.
Let be the following signal:
dt=.01;
t=[0:dt:10];
x0=10*sin(t);
x=10*sin(t)+10*cos(t); % 2nd tone has phase shift equivalent to pi/4 rad
xd1=fftshift(x);
X=fft(x);
Xd=fft(xd1);
figure(1);plot([1:1:length(X)],abs(X),'b',[1:1:length(X)],fftshift(abs(X)),'g');grid on;
legend('|X|','fftshift(|X|)');
figure(2);plot([1:1:length(X)],angle(X),'b',[1:1:length(X)],fftshift(angle(X)),'g');grid on;
legend('arg(X)','fftshift(arg(X))');
If you apply a frequency operation directly on time domain, for this example you get the following:
figure(3);plot(t,x0,'b',t,x,'r');grid on
text(2.63,x0(find(t==2.63)),'\leftarrow 10*sin(t)','FontSize',14);
text(1.16,x(find(t==1.16)),'\leftarrow 10*sin(t)+10*cos(t)','FontSize',14);
figure(4);plot(t,x0,t,xd1);
text(5.38,x0(find(t==5.38)),'\leftarrow 10*sin(t)','FontSize',14);grid on;
text(2.41,xd1(find(t==2.41)),'\leftarrow fftshift(10*sin(t)+10*cos(t))','FontSize',14);
the typical phase imbalance oscilloscope also helps:
figure(5);plot(x0,x,x0,xd1);
As explained in MATLAB help, there is further phase cross-over when working with 2D signals
. If you find this answer of any help solving your question
please mark it as accepted answer,
thanks in advance
John
  댓글 수: 1
Jan
Jan 2017년 2월 24일
John BG has accepted this answer by his own. It is not clear, if it helps the OP.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 6월 9일
No, if your data is in the time domain, then using fftshift(x) before usng fft() would only be before the case where you had negative time represented in your data and time zero was at the middle of the data. The first version you gave is significantly more likely for time domain data: it assumes the data starts at time 0 and it shifts the result of the fft so as to center the plot in the frequency domain.
You only use fftshift() twice if the data you are using fft() or ifft() on is centered in the array.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by