<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/288745</link>
    <title>MATLAB Central Newsreader - Summation</title>
    <description>Feed for thread: Summation</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2013 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.nl/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 06 Aug 2010 22:45:05 +0000</pubDate>
      <title>Summation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/288745#769356</link>
      <author>Mohammad </author>
      <description>Dear reader,&lt;br&gt;
&lt;br&gt;
I have a vector with r entries which are imputed previously. I want to PLOT a function v(x), such that v=@x Star(1,1)*sin(pi*x)+Star(1,2)*sin(2*pi*x)+Star(1,3)*sin(3*pi*x)+....Star(1,n)*sin(n*pi*x)+...Star(1,r-1)*sin((r-1)*pi*x)+Star(1,r)*sin(r*pi*x)&lt;br&gt;
&lt;br&gt;
Is there a simple way to do this using matrix summation.&lt;br&gt;
&lt;br&gt;
(P.S. I only need to plot it, so if there is a way to  not need to create a function, I'll take it)&lt;br&gt;
&lt;br&gt;
This is what I though of so far:&lt;br&gt;
Yarr=ones(r,200)&lt;br&gt;
for i = 1:r&lt;br&gt;
for x = 1:200&lt;br&gt;
Yarr(i,x)=Star(1,i)*sin(i*pi*x)&lt;br&gt;
end&lt;br&gt;
end</description>
    </item>
    <item>
      <pubDate>Sat, 07 Aug 2010 16:59:04 +0000</pubDate>
      <title>Re: Summation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/288745#769430</link>
      <author>Matt J </author>
      <description>"Mohammad " &amp;lt;jaber2@uni.uiuc.edu&amp;gt; wrote in message &amp;lt;i3i39h$44i$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Dear reader,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have a vector with r entries which are imputed previously. I want to PLOT a function v(x), such that v=@x Star(1,1)*sin(pi*x)+Star(1,2)*sin(2*pi*x)+Star(1,3)*sin(3*pi*x)+....Star(1,n)*sin(n*pi*x)+...Star(1,r-1)*sin((r-1)*pi*x)+Star(1,r)*sin(r*pi*x)&lt;br&gt;
=================&lt;br&gt;
&lt;br&gt;
v=@(x) sum( Star.*sin(   pi*x(:)*(1:r)  )  ,2 );&lt;br&gt;
plot(1:200,v(1:200));</description>
    </item>
    <item>
      <pubDate>Sat, 07 Aug 2010 17:17:04 +0000</pubDate>
      <title>Re: Summation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/288745#769434</link>
      <author>Matt J </author>
      <description>"Matt J " &amp;lt;mattjacREMOVE@THISieee.spam&amp;gt; wrote in message &amp;lt;i3k3co$ldr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; v=@(x) sum(    bsxfun(@times, sin(   pi*x(:)*(1:r)  )  ,    2 );&lt;br&gt;
&amp;gt; plot(1:200,v(1:200));&lt;br&gt;
==============&lt;br&gt;
&lt;br&gt;
Sorry, make that&lt;br&gt;
&lt;br&gt;
v=@(x) sum(    bsxfun( @times, sin(   pi*x(:)*(1:r)  ),Star)  ,    2 ).';&lt;br&gt;
&lt;br&gt;
plot(1:200,v(1:200));</description>
    </item>
    <item>
      <pubDate>Sat, 07 Aug 2010 17:45:04 +0000</pubDate>
      <title>Re: Summation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/288745#769438</link>
      <author>Roger Stafford</author>
      <description>"Matt J " &amp;lt;mattjacREMOVE@THISieee.spam&amp;gt; wrote in message &amp;lt;i3k4eg$qp0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
\&amp;gt; v=@(x) sum(    bsxfun( @times, sin(   pi*x(:)*(1:r)  ),Star)  ,    2 ).';&lt;br&gt;
- - - - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;You don't need bsxfun for this one:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;v = @(x) sin(pi*x(:)*(1:r))*Star.';&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Sat, 07 Aug 2010 18:54:03 +0000</pubDate>
      <title>Re: Summation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/288745#769448</link>
      <author>Mohammad </author>
      <description>"Roger Stafford" &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in message &amp;lt;i3k630$8dp$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Matt J " &amp;lt;mattjacREMOVE@THISieee.spam&amp;gt; wrote in message &amp;lt;i3k4eg$qp0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; \&amp;gt; v=@(x) sum(    bsxfun( @times, sin(   pi*x(:)*(1:r)  ),Star)  ,    2 ).';&lt;br&gt;
&amp;gt; - - - - - - - - - - -&lt;br&gt;
&amp;gt;   You don't need bsxfun for this one:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  v = @(x) sin(pi*x(:)*(1:r))*Star.';&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
&lt;br&gt;
Thanks everyone. Just for educational purpose (So I can do this in the future) does the x(:) mean that x is changing, and what does the .' after Star signify.&lt;br&gt;
&lt;br&gt;
THANKS! this made my program a whole lot simpler.&lt;br&gt;
&lt;br&gt;
Cordially, Mohammad</description>
    </item>
    <item>
      <pubDate>Sat, 07 Aug 2010 20:48:04 +0000</pubDate>
      <title>Re: Summation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/288745#769460</link>
      <author>Matt Fig</author>
      <description>"Mohammad " &amp;lt;jaber2@uni.uiuc.edu&amp;gt; wrote in message &lt;br&gt;
&amp;gt; Thanks everyone. Just for educational purpose (So I can do this in the future) does the x(:) mean that x is changing, and what does the .' after Star signify.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; THANKS! this made my program a whole lot simpler.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Cordially, Mohammad&lt;br&gt;
&lt;br&gt;
Look&lt;br&gt;
&lt;br&gt;
doc colon&lt;br&gt;
doc transpose</description>
    </item>
    <item>
      <pubDate>Sat, 07 Aug 2010 20:57:03 +0000</pubDate>
      <title>Re: Summation</title>
      <link>http://www.mathworks.nl/matlabcentral/newsreader/view_thread/288745#769462</link>
      <author>Roger Stafford</author>
      <description>"Mohammad " &amp;lt;jaber2@uni.uiuc.edu&amp;gt; wrote in message &amp;lt;i3ka4b$cd0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Roger Stafford" &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in message &amp;lt;i3k630$8dp$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; "Matt J " &amp;lt;mattjacREMOVE@THISieee.spam&amp;gt; wrote in message &amp;lt;i3k4eg$qp0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; \&amp;gt; v=@(x) sum(    bsxfun( @times, sin(   pi*x(:)*(1:r)  ),Star)  ,    2 ).';&lt;br&gt;
&amp;gt; &amp;gt; - - - - - - - - - - -&lt;br&gt;
&amp;gt; &amp;gt;   You don't need bsxfun for this one:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;  v = @(x) sin(pi*x(:)*(1:r))*Star.';&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Roger Stafford&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks everyone. Just for educational purpose (So I can do this in the future) does the x(:) mean that x is changing, and what does the .' after Star signify.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; THANKS! this made my program a whole lot simpler.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Cordially, Mohammad&lt;br&gt;
- - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;No, x(:) makes a column vector out of the elements of x just in case your x was a row vector.  (Actually it will make a column vector out of a matrix too.)  The .' after Star takes its transpose.  This is necessary so that the number of columns in sin(pi*x(:)*(1:r)) will equal the number of rows in Star.' and yield a valid matrix multiplication with the * operation in between them.  You should read up in your matlab manual about indexing and matrix multiplication.  It's an important part of one's matlab education.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
  </channel>
</rss>
