<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Evaluate Function using vectors' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Evaluate Function using vectors' posted on the 'Matlab' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Wed, 23 May 2012 13:47:32 -0700</pubDate>
    <lastBuildDate>Wed, 23 May 2012 13:47:32 -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>Evaluate Function using vectors</title>
      <link>http://www.programmersheaven.com/mb/ctocplusplustomatlab/408841/408841/evaluate-function-using-vectors/</link>
      <description>How would I evaluate this using a row vector? (pref no loops! (its horrible!) &lt;br /&gt;
function [y, err] = arctanseries(x,n)  -&amp;gt; x is the row vector, n is just an integer.&lt;br /&gt;
&lt;br /&gt;
Thank you in advance to all who try! &lt;br /&gt;
&lt;pre class="sourcecode"&gt;

function [y, err] = arctanseries(x,n)

if(x&amp;gt;=(-1))&amp;amp;(x&amp;lt;=1)
    power = [];
    nom = [];
    denom = [];
    neg = [];
    answer = [];
    
    % Vector neg, alternating values, 1 -1 1 -1 for arctanseries
    neg = ones(1,n);
    neg(2:2:end) = -1;
    
    % Vector power, starts at 1, increases by 2 for n-1 times
    power = 1:2:((2*n)-1);
    
    % Vector denom, denominator of the arctanseries. stats at 1
    denom = 1:2:((2*n)-1);
    
    % Vector nom, nominator equals x
    nom = (ones(1,n))*x;
    
    % solve arctan series 
    answer = nom .^ power;
    answer = answer .* neg;
    answer = sum(answer ./ denom);
    
    % ***Output***
    y = answer;
else
    err = error('Input Error: x must be between -1 and 1 inclusive')
end

&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ctocplusplustomatlab/408841/408841/evaluate-function-using-vectors/</guid>
      <pubDate>Wed, 04 Nov 2009 18:25:50 -0700</pubDate>
      <category>Matlab</category>
    </item>
  </channel>
</rss>
