Why does FFT subtract PI/2 phase shift for sine wave
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.
Accepted Answer
More Answers (0)
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!