1

Using the code,

syms x(t) 
y=x^2
diff(y,t)
diff(y,x)

I get the following error:

2*D(x)(t)*x(t)
Error using sym/diff (line 26)
All arguments, except for the first one, must not be symbolic functions.

Is there a way to tackle this? Thanks for your time.

Safvan P
  • 23
  • 2
  • See my answer to this very similar question: [How to implement a derivative of a symbolic function by a 'symfun' in Matlab?](http://stackoverflow.com/questions/27085362/how-to-implement-a-derivative-of-a-symbolic-function-by-a-symfun-in-matlab) – horchler Jan 05 '15 at 21:19

1 Answers1

1

I dont know much about the Symbolic Math Toolbox, but taking a derivative wrt to a function does not seem to be supported (at least in a direct fashion) for diff.

You can substitute a variable, compute a derivative, and substitute the function back. Like so:

syms z
subs(diff(subs(y,x,z),z),z,x)

ans(t) = 2*x(t)
MeMyselfAndI
  • 1,320
  • 7
  • 12