title: summing functions handles in matlab
body: <p>Hi<br>
  I am trying to sum two function handles, but it doesn't work.
  for example:   </p>
  
  <blockquote>
    <blockquote>
      <p>y1=@(x)(x*x);<br>
      y2=@(x)(x*x+3*x);<br>
      y3=y1+y2  </p>
    </blockquote>
  </blockquote>
  
  <p>The error I receive is "??? Undefined function or method 'plus' for input arguments of type 'function_handle'." </p>
  
  <p>This is just a small example, in reality I actually need to iteratively sum about 500 functions that are dependent on each other.</p>
  
  <p><strong>EDIT</strong><br>
  The solution by Clement J. indeed works but I couldn't manage to generalize this into a loop and ran into a problem. I have the function <code>s=@(x,y,z)((1-exp(-x*y)-z)*exp(-x*y));</code> And I have a vector v that contains 536 data points and another vector w that also contains 536 data points. My goal is to sum up s(v(i),y,w(i)) for i=1...536 Thus getting one function in the variable y which is the sum of 536 functions. The syntax I tried in order to do this is: </p>
  
  <pre><code>sum=@(y)(s(v(1),y,z2(1))); 
  for i=2:536 
    sum=@(y)(sum+s(v(i),y,z2(i))) 
  end
  </code></pre>