<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252052</link>
    <title>MATLAB Central Newsreader - FFT on MATLAB with Graphical Illustration</title>
    <description>Feed for thread: FFT on MATLAB with Graphical Illustration</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>Sat, 23 May 2009 19:32:01 -0400</pubDate>
      <title>FFT on MATLAB with Graphical Illustration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252052#651928</link>
      <author>Kola Ogidi</author>
      <description>Hello,&lt;br&gt;
&lt;br&gt;
I am trying to produce the FFT for a 16Hz sine wave sampled at 1024Hz on MATLAB and also illlustrate this graphically on MATLAB. &lt;br&gt;
&lt;br&gt;
I have tried the following code:&lt;br&gt;
fs=1024; &lt;br&gt;
f=16;&lt;br&gt;
t1=0;&lt;br&gt;
tstep=(1/1024);&lt;br&gt;
t2=4/1024;&lt;br&gt;
t=[t1:tstep:t2];&lt;br&gt;
x=sin(2*pi*f*t);&lt;br&gt;
X=fft(x);&lt;br&gt;
Sampleresp=abs(X);&lt;br&gt;
N=length(X);&lt;br&gt;
F=[0:N-1]*fs/N;&lt;br&gt;
stem(F,Sampleresp);&lt;br&gt;
&lt;br&gt;
However, my output figure is not showing a peak at 16Hz as I expect.  Could you please explain to me what changes I need to make to my code to yield the correct output/graph.&lt;br&gt;
&lt;br&gt;
Thank you.</description>
    </item>
    <item>
      <pubDate>Sat, 23 May 2009 20:09:02 -0400</pubDate>
      <title>Re: FFT on MATLAB with Graphical Illustration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252052#651931</link>
      <author>Sadik </author>
      <description>Please replace line starting with t2 by the following:&lt;br&gt;
&lt;br&gt;
t2 = 63/1024;&lt;br&gt;
&lt;br&gt;
This is because, although we think that we have only one period of the signal, in the discrete world, things are considered to be periodic. Therefore, you should have a full period of your sine wave. Your period is T = 1/16 which is equal to 64/1024. But since you started from 0/1024, which will have the identical signal amplitude with 64/1024, we will exclude 64/1024 and end the sequence at 63/1024.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Kola Ogidi&quot; &amp;lt;jreal_kkoo@hotmail.com&amp;gt; wrote in message &amp;lt;gv9ivh$97d$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I am trying to produce the FFT for a 16Hz sine wave sampled at 1024Hz on MATLAB and also illlustrate this graphically on MATLAB. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have tried the following code:&lt;br&gt;
&amp;gt; fs=1024; &lt;br&gt;
&amp;gt; f=16;&lt;br&gt;
&amp;gt; t1=0;&lt;br&gt;
&amp;gt; tstep=(1/1024);&lt;br&gt;
&amp;gt; t2=4/1024;&lt;br&gt;
&amp;gt; t=[t1:tstep:t2];&lt;br&gt;
&amp;gt; x=sin(2*pi*f*t);&lt;br&gt;
&amp;gt; X=fft(x);&lt;br&gt;
&amp;gt; Sampleresp=abs(X);&lt;br&gt;
&amp;gt; N=length(X);&lt;br&gt;
&amp;gt; F=[0:N-1]*fs/N;&lt;br&gt;
&amp;gt; stem(F,Sampleresp);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; However, my output figure is not showing a peak at 16Hz as I expect.  Could you please explain to me what changes I need to make to my code to yield the correct output/graph.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you.</description>
    </item>
    <item>
      <pubDate>Sat, 23 May 2009 20:51:01 -0400</pubDate>
      <title>Re: FFT on MATLAB with Graphical Illustration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252052#651938</link>
      <author>Kola Ogidi</author>
      <description>Thank you so very much, Sadik.  My output figure is now showing a peak at approximately 16Hz.  I believe I just need to tweak around with the MATLAB equivalent for zoom to confirm my results.  Thanks again.&lt;br&gt;
&amp;nbsp;&lt;br&gt;
Kola</description>
    </item>
  </channel>
</rss>

