<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Understanding code' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Understanding code' posted on the 'Matlab' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 09:22:38 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 09:22:38 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Understanding code</title>
      <link>http://www.programmersheaven.com/mb/ctocplusplustomatlab/431170/431170/understanding-code/</link>
      <description>Hi All,&lt;br /&gt;
&lt;br /&gt;
Okay so I am a C programmer who is now programming in MATLAB. For our first college asignment I have to plot 3 sinusoid graphs of 4000 Hz with 25 samples per period. I also have to start from -T. The thing is I have the code. The whole class has the code i just want to understand it better.&lt;br /&gt;
Things I don't understand in the code:&lt;br /&gt;
* what is the point of fs&lt;br /&gt;
*i dont get how 3 graphs result from this&lt;br /&gt;
&lt;br /&gt;
the x1-x3 functions are defined by our teacher.&lt;br /&gt;
&lt;br /&gt;
Thank you:&lt;br /&gt;
&lt;br /&gt;
code:&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;
f = 22050;				%frequency of sinusoids&lt;br /&gt;
T = 1/f;					%period of sinusoids&lt;br /&gt;
fs = 20/T;				%at least 20 samples per period&lt;br /&gt;
tt = -T:(1/fs):2*T;	%3 cycles starts at a negative time equal to -T&lt;br /&gt;
x1 = 24*cos(2*pi*f*tt+8.8);&lt;br /&gt;
x2 = 20*cos(2*pi*f*tt+2);&lt;br /&gt;
x3 = x1+x2;&lt;br /&gt;
&lt;br /&gt;
subplot(311);&lt;br /&gt;
plot(tt, x1), grid on;&lt;br /&gt;
title('x1');&lt;br /&gt;
axis tight&lt;br /&gt;
subplot(312);&lt;br /&gt;
plot(tt, x2), grid on;&lt;br /&gt;
title('x2');&lt;br /&gt;
axis tight&lt;br /&gt;
subplot(313);&lt;br /&gt;
plot(tt, x3), grid on;&lt;br /&gt;
title('x3');&lt;br /&gt;
xlabel('Time (sec)');&lt;br /&gt;
axis tight&lt;br /&gt;
orient tall&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ctocplusplustomatlab/431170/431170/understanding-code/</guid>
      <pubDate>Sun, 03 Feb 2013 09:22:14 -0700</pubDate>
      <category>Matlab</category>
    </item>
    <item>
      <title>Re: Understanding code</title>
      <link>http://www.programmersheaven.com/mb/ctocplusplustomatlab/431170/431189/re-understanding-code/#431189</link>
      <description>Hi,&lt;br /&gt;
&lt;br /&gt;
When I paste your code into my Matlab I get everything like I should.&lt;br /&gt;
x3 = x1+x2; means something like (in C):&lt;br /&gt;
suppose that x1, x2 and x3 has the same elements in table, &lt;br /&gt;
and it is like 25 (don't know how to get number of elements in table in C, in Matlab you do length(x1) :P)&lt;br /&gt;
&lt;br /&gt;
for (i=1;i&amp;lt;=25;i++)&lt;br /&gt;
{&lt;br /&gt;
x3(i) = x1(i) + x2(i);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
If you change fs into higher value, you will get finer charts.&lt;br /&gt;
Try enter fs = 5/Tp and see difference :) It means how many points in 1 second of simulation will be in chart.&lt;br /&gt;
&lt;br /&gt;
Best regards,&lt;br /&gt;
Marcin&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ctocplusplustomatlab/431170/431189/re-understanding-code/#431189</guid>
      <pubDate>Mon, 04 Feb 2013 10:06:23 -0700</pubDate>
      <category>Matlab</category>
    </item>
  </channel>
</rss>