title: Matlab find min/max of function
body: <p>I'm trying to write an M-file that finds the max/min of a function, given a certain range.</p>
  
  <p>Let's say I have defined an equation in the command window like so:</p>
  
  <pre><code>&gt; y = @(x) -1*x^2 + 3
  y =
  
    function_handle with value:
  
      @(x)-1*x^2+3
  </code></pre>
  
  <p>And let's say my desired range is from -3 to 3... So I would start my M-file with</p>
  
  <pre><code>function fminmax = input(f, lowerbound, upperbound)
  </code></pre>
  
  <p>but then what would I use? I've been googling for a while and I cant find anything helpful. Please help!</p>