22 views (last 30 days)

Show older comments

According to the explanation on the internet, the phase of the y=A*sin(2*pi*x+Phi) is 2*pi*x+Phi, and the initial phase is the result when x is zero.so the initial phase of the signal y=sin(2*pi*x) is zero. But when i use fft to calculate the initial phase , i got the result is -90. The matlab code is as follows.

I want to know why the two result is different.thank you very much.

t=linspace(0,2-0.0625,32);%

x=sin(2*pi*t);

figure,plot(t,x);

X=fft(x);

figure,stem(abs(X));

figure;

stem(angle(X)/pi*180);

Chris Turnes
on 29 Sep 2015

When taking the FFT of an input array, the first value in the resulting output is the DC bias of the input . Since your input signal x is a pure tone sinusoid that aligns with one of the frequency bins of the DFT, the DC component should be 0.

However, because of round-off error, you don't get exactly 0; instead, you get -8.6529e-16. When you take the phase of this element, it's the same as taking the phase of -1, and you get -pi radians.

However, if you plot the magnitude of your FFT result

plot(abs(X))

you'll see that the frequency of your pure tone sinusoid corresponds to the third DFT bin. So, if you look at the angle of this component, you'll find

>> angle(X(3))/pi*180

ans =

-90.0000

So, now your answer is -90 degrees. Why? The phase of sin(0) is 0 if you're defining the phase relative to a zero-phase sine -- but the phase of the DFT coefficients is relative to a zero-phase cosine. This is why you get a phase of -pi/2 in radians (-90 degrees).

If you need to convince yourself this is the case, try repeating the process, but replace x with

x=cos(2*pi*x-pi/2)

You'll see you get the same FFT results (minus some roundoff error).

Incidentally, if you wanted the phase of the FFT results to be relative to a zero-phase sine, you don't have to do much different; you just have to multiply your input by 1j:

>> X = fft(1j*x);

>> angle(X(3))*180/pi

ans =

-1.5876e-14

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

Start Hunting!