Why does FFT subtract PI/2 phase shift for sine wave
7 views (last 30 days)
Show older comments
I know that very similar questions have already been asked, but I'm still confused. If I do the following:
t = 0:0.0001:1.0;
signal = 10*sin(2*pi*10*t-pi/2);
n = length(signal);
z = fft(signal, n); %do the actual work
%generate the vector of frequencies
halfn = n / 2;
deltaf = 1 / ( n / ScanRate);
frq = (0:(halfn-1)) * deltaf;
% convert from 2 sided spectrum to 1 sided
%(assuming that the input is a real signal)
amp(1) = abs(z(1)) ./ (n);
amp(2:halfn) = abs(z(2:halfn)) ./ (n / 2);
phase = angle(z(1:halfn));
When I plot the phase versus the frequency, I get a phase shift of about -pi at a frequency of 10 Hz. I believe that this is coming from the fact that the sine wave is shifted pi/2 from the cosine wave. However, if this was an arbitrary signal, I wouldn't know if it was sine or cosine input. And, if I use this phase shift directly with a sine wave to do the inverse transform, it won't match my original input signal. Does this mean that the basis function in some sense is a cosine wave?
Will someone please clear this confusion up? thanks so much.
0 Comments
Accepted Answer
Rick Rosson
on 7 Oct 2014
Think of it this way. Cosine is the real-part of the complex exponential, whereas sine is the real-part of the complex exponential multiplied by -i. And -i is equivalent to exp(-i*pi/2). So that means that sine is out-of-phase by -pi/2 compared with cosine. In other words,
sin(w*t) = cos(w*t - pi/2)
So that means the phase of cosine is 0, whereas the phase of sine is -pi/2.
2 Comments
Rick Rosson
on 7 Oct 2014
Edited: Rick Rosson
on 7 Oct 2014
It is not specified in the fft because the fft is a mathematically correct implementation of the Discrete Fourier Transform (DFT), which is a well known and precisely defined mathematical transform. The DFT is, in turn, specified in terms of complex exponentials, which are related to sine and cosine by Euler's well-known formula.
At the risk of oversimplifying, the real-part of Euler's formula is cosine, whereas the imaginary part is sine. So, assuming a real-valued signal, it is a convenient method to assume that the signal of interest can be represented as the real-part of some other, complex signal (which is called an analytic signal). Since cosine is the real-part, and sine is the imaginary-part, it is merely a common convention to specify that cosine has a phase of 0. It then follows that sine has a phase of -pi/2.
It would be equally valid to specify that sine has a phase of 0, as long as you then conclude that cosine has a phase of +pi/2. And in this case, the signal of interest would represent the imaginary-part of some analytic signal.
In other words, the absolute phase is completely arbitrary. All that matters is the relative phase. And that you follow a consistent convention.
More Answers (0)
See Also
Categories
Find more on Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!