title: Transforming Symbolic Derivatives into Actual Symbols
body: <p>I need to take derivatives in Matlab of a lot of equations w.r.t. generic functions, which will provide me with generic derivatives, of the type:</p>
  
  <pre><code>diff(f(x,y),x)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>D([1],f(x,y)).
  </code></pre>
  
  <p>What I need is to transform these derivatives into actual symbolic variables, in order to be able to use <code>solve</code>, etc. What I am doing now, but which is highly inefficient, is brute force string replacement. Here is a minimal working example of what I am doing:</p>
  
  <pre><code>syms x y
  f(x,y) = sym('f(x,y)')
  jacobian(f)
  first_d = jacobian(f)
  strrep(char(first_d),'D([1], f)(x, y)','fx')
  </code></pre>
  
  <p>In my real application, I have lots of derivatives to take from lots of equations, so looping such replacements is not the smartest thing to do. Can anybody shed some light into a more efficient solution?</p>