title: Gradient of a function handle
body: <p>I'm trying to calculate the gradient of a function handle in Matlab, for later use.</p>
  
  <p>e.G:</p>
  
  <pre><code>fun = @(x) x(1)^2+ 2*x(2)
  
  grad_fun = @(x) gradient(fun(x))
  </code></pre>
  
  <p>If I check this with: <code>grad_fun([1;1])</code> I receive 0.</p>
  
  <p>For all values, all I get are zeroes.</p>
  
  <p>Can somebody help me ?</p>
  
  <p>Thanks in advance!</p>