title: Evaluate a constant expression in matlab
body: <p>I am currently writing a script that takes a function and interval from the user and then evaluates the integral using the trapezoid method. The script also evaluates the error. To do so, I need to use the second derivative of the function entered. In the case where the second derivative is a constant or 0, I get the Too many input arguments error. Here is a small section of the code to illustrate where the error happens:</p>
  <pre><code>%integrate x^2 from 0 to 5
  syms x
  func = x^2;
  deriv = diff(func,x,2);
  func = matlabFunction(func);
  deriv = matlabFunction(deriv);
  deriv(0:0.01:5); %&lt;- error since deriv = 2, needed to compute the error on the trapezoid method.
  </code></pre>
  <p>Is there a way for matlab to evaluate the vector 0:0.01:5 and return a vector of the same size with the value &quot;2&quot; for each value passed? Whether the  function deriv is a constant or not is unknown and depends on what the user enters.</p>