Hi all,
I'm new to matlab FFT algorithm, I'm doing some tests with a simple sine
function. I've got two questions: one about amplitude and the other
about phase.
The code is this:
wave = sin(linspace(0,2*pi,100));
fs = 10000; % Sampling frequency
n = length(wave);
Y = fft(wave);
A = 2*abs(Y)/n; % Amplitude spectrum
phase = angle(Y)*180/pi;
1) Why am I getting amplitude A(2) = 1 only if I multiply abs(Y) by 2?
Ettos <matmailRIMUOVIQUESTO@europe.com> wrote in message <4ae09934$0$831$4fafbaef@reader5.news.tin.it>...
> Hi all,
> I'm new to matlab FFT algorithm, I'm doing some tests with a simple sine
> function. I've got two questions: one about amplitude and the other
> about phase.
> The code is this:
>
> wave = sin(linspace(0,2*pi,100));
> fs = 10000; % Sampling frequency
> n = length(wave);
> Y = fft(wave);
> A = 2*abs(Y)/n; % Amplitude spectrum
> phase = angle(Y)*180/pi;
>
> 1) Why am I getting amplitude A(2) = 1 only if I multiply abs(Y) by 2?
Because
sin(t)=(exp(jt)-exp(-jt)) /2j
from which you can clearly see that the Fourier coefficients are +/- 1/2j. So, you expect their amplitude to be 0.5
> 2) Why am I getting phase(2) = -90 and not zero?
Ettos <matmailRIMUOVIQUESTO@europe.com> wrote in message <4ae09934$0$831$4fafbaef@reader5.news.tin.it>...
> Hi all,
> I'm new to matlab FFT algorithm, I'm doing some tests with a simple sine
> function. I've got two questions: one about amplitude and the other
> about phase.
> The code is this:
>
> wave = sin(linspace(0,2*pi,100));
> fs = 10000; % Sampling frequency
> n = length(wave);
> Y = fft(wave);
> A = 2*abs(Y)/n; % Amplitude spectrum
> phase = angle(Y)*180/pi;
>
> 1) Why am I getting amplitude A(2) = 1 only if I multiply abs(Y) by 2?
>
> 2) Why am I getting phase(2) = -90 and not zero?
>
> Thank you very much!
> Matteo.
hint: fft returns a complex spec. ie one single-freq-signal --> two peaks
solution: just normalize by (n/2)
>
> Because
>
> sin(t)=(exp(jt)-exp(-jt)) /2j
>
> from which you can clearly see that the Fourier coefficients are +/- 1/2j. So, you expect their amplitude to be 0.5
Thank you for you answer!
Maybe... math is my problem!
I thought that Fourier coefficients were real and in my case are a =
1.56 and b = 49.71 (FT = a - ib ). What do you mean for Fourier
coefficients?
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.