<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263883</link>
    <title>MATLAB Central Newsreader - Questions about matlab FFT</title>
    <description>Feed for thread: Questions about matlab FFT</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 22 Oct 2009 17:41:07 -0400</pubDate>
      <title>Questions about matlab FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263883#689085</link>
      <author>Ettos</author>
      <description>Hi all,&lt;br&gt;
I'm new to matlab FFT algorithm, I'm doing some tests with a simple sine &lt;br&gt;
function. I've got two questions: one about amplitude and the other &lt;br&gt;
about phase.&lt;br&gt;
The code is this:&lt;br&gt;
&lt;br&gt;
wave = sin(linspace(0,2*pi,100));&lt;br&gt;
fs = 10000; % Sampling frequency&lt;br&gt;
n = length(wave);&lt;br&gt;
Y = fft(wave);&lt;br&gt;
A = 2*abs(Y)/n; % Amplitude spectrum&lt;br&gt;
phase = angle(Y)*180/pi;&lt;br&gt;
&lt;br&gt;
1) Why am I getting amplitude A(2) = 1 only if I multiply abs(Y) by 2?&lt;br&gt;
&lt;br&gt;
2) Why am I getting phase(2) = -90 and not zero?&lt;br&gt;
&lt;br&gt;
Thank you very much!&lt;br&gt;
Matteo.</description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 18:00:20 -0400</pubDate>
      <title>Re: Questions about matlab FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263883#689093</link>
      <author>Matt </author>
      <description>Ettos &amp;lt;matmailRIMUOVIQUESTO@europe.com&amp;gt; wrote in message &amp;lt;4ae09934$0$831$4fafbaef@reader5.news.tin.it&amp;gt;...&lt;br&gt;
&amp;gt; Hi all,&lt;br&gt;
&amp;gt; I'm new to matlab FFT algorithm, I'm doing some tests with a simple sine &lt;br&gt;
&amp;gt; function. I've got two questions: one about amplitude and the other &lt;br&gt;
&amp;gt; about phase.&lt;br&gt;
&amp;gt; The code is this:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; wave = sin(linspace(0,2*pi,100));&lt;br&gt;
&amp;gt; fs = 10000; % Sampling frequency&lt;br&gt;
&amp;gt; n = length(wave);&lt;br&gt;
&amp;gt; Y = fft(wave);&lt;br&gt;
&amp;gt; A = 2*abs(Y)/n; % Amplitude spectrum&lt;br&gt;
&amp;gt; phase = angle(Y)*180/pi;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1) Why am I getting amplitude A(2) = 1 only if I multiply abs(Y) by 2?&lt;br&gt;
&lt;br&gt;
Because &lt;br&gt;
&lt;br&gt;
sin(t)=(exp(jt)-exp(-jt)) /2j&lt;br&gt;
&lt;br&gt;
from which you can clearly see that the Fourier coefficients are +/- 1/2j. So, you expect their amplitude to be 0.5&lt;br&gt;
&lt;br&gt;
&amp;gt; 2) Why am I getting phase(2) = -90 and not zero?&lt;br&gt;
&lt;br&gt;
Because your signal is a sine, not a cosine.</description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 18:16:21 -0400</pubDate>
      <title>Re: Questions about matlab FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263883#689099</link>
      <author>Lars </author>
      <description>Ettos &amp;lt;matmailRIMUOVIQUESTO@europe.com&amp;gt; wrote in message &amp;lt;4ae09934$0$831$4fafbaef@reader5.news.tin.it&amp;gt;...&lt;br&gt;
&amp;gt; Hi all,&lt;br&gt;
&amp;gt; I'm new to matlab FFT algorithm, I'm doing some tests with a simple sine &lt;br&gt;
&amp;gt; function. I've got two questions: one about amplitude and the other &lt;br&gt;
&amp;gt; about phase.&lt;br&gt;
&amp;gt; The code is this:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; wave = sin(linspace(0,2*pi,100));&lt;br&gt;
&amp;gt; fs = 10000; % Sampling frequency&lt;br&gt;
&amp;gt; n = length(wave);&lt;br&gt;
&amp;gt; Y = fft(wave);&lt;br&gt;
&amp;gt; A = 2*abs(Y)/n; % Amplitude spectrum&lt;br&gt;
&amp;gt; phase = angle(Y)*180/pi;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1) Why am I getting amplitude A(2) = 1 only if I multiply abs(Y) by 2?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 2) Why am I getting phase(2) = -90 and not zero?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you very much!&lt;br&gt;
&amp;gt; Matteo.&lt;br&gt;
&lt;br&gt;
hint: fft returns a complex spec. ie one single-freq-signal --&amp;gt; two peaks&lt;br&gt;
solution: just normalize by (n/2)&lt;br&gt;
&lt;br&gt;
but:&lt;br&gt;
&lt;br&gt;
sin(linspace(0,2*pi,100)) ???&lt;br&gt;
&lt;br&gt;
what happened to your fs?</description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 18:50:28 -0400</pubDate>
      <title>Re: Questions about matlab FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263883#689103</link>
      <author>Ettos</author>
      <description>Lars wrote:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; hint: fft returns a complex spec. ie one single-freq-signal --&amp;gt; two peaks&lt;br&gt;
&amp;gt; solution: just normalize by (n/2)&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
ok! Thanks!&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; sin(linspace(0,2*pi,100)) ???&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; what happened to your fs?&lt;br&gt;
&lt;br&gt;
In what sense?&lt;br&gt;
I supposed fs to be 10000Hz just to check if the ftt was right (sine &lt;br&gt;
frequency of 100Hz).</description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 19:04:37 -0400</pubDate>
      <title>Re: Questions about matlab FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263883#689106</link>
      <author>Ettos</author>
      <description>Matt wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Because &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; sin(t)=(exp(jt)-exp(-jt)) /2j&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; from which you can clearly see that the Fourier coefficients are +/- 1/2j. So, you expect their amplitude to be 0.5&lt;br&gt;
&lt;br&gt;
Thank you for you answer!&lt;br&gt;
&lt;br&gt;
Maybe... math is my problem!&lt;br&gt;
I thought that Fourier coefficients were real and in my case are a = &lt;br&gt;
1.56 and b = 49.71 (FT = a - ib ). What do you mean for Fourier &lt;br&gt;
coefficients?&lt;br&gt;
&lt;br&gt;
Matteo.</description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 20:11:25 -0400</pubDate>
      <title>Re: Questions about matlab FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263883#689122</link>
      <author>Matt </author>
      <description>Ettos &amp;lt;matmailRIMUOVIQUESTO@europe.com&amp;gt; wrote in message &amp;lt;4ae0acc7$0$817$4fafbaef@reader5.news.tin.it&amp;gt;...&lt;br&gt;
&amp;nbsp;What do you mean for Fourier &lt;br&gt;
&amp;gt; coefficients?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I just meant the values of the spectrum</description>
    </item>
  </channel>
</rss>

