title: How to implement a derivative of a symbolic function by a 'symfun' in Matlab?
body: <p>Here is my Matlab program:</p>
  
  <pre><code>syms x(t) t;
  f = x^2 + 5;
  </code></pre>
  
  <p>And the result of <code>f</code>: </p>
  
  <pre><code>f(t) = x(t)^2 + 5
  </code></pre>
  
  <p>Both <code>f</code> and <code>x</code> are of class <code>symfun</code> in Matlab. I want the result of df/dx, which is equal to <code>2*x(t)</code>. 
  I tried this in Matlab:</p>
  
  <pre><code>diff(f, x);
  </code></pre>
  
  <p>and got the following errors:</p>
  
  <pre><code>Error using mupadmex
  Error in MuPAD command: The variable is
  invalid. [stdlib::diff]
  Error in sym/diff (line 57)
      R = mupadmex('symobj::diff', S.s, x.s,
      int2str(n));
  </code></pre>
  
  <p>How can df/dx be obtained in Matlab?</p>