How to solve for a derivative using symbols?

This is simple, but I cannot find the answer.
Here is my example:
syms u c ut
f= symfun(u-c, [u c])
ut = sym('u(c)')
df = subs(f,u,ut)
dff = diff(df,c)==0
Now I would like to solve it for du/dc, the answer is simple du/dc=1. But I can't do it, in reality my problems are much more complicated. Is it possible to substitute derivative expression into a variable following a derivative. I can create:
dudc=symfun(diff(ut,c), [u c])
but dudc is not recognize if I try to solve dff with it.
Thanks
Jerome

Answers (1)

You have
f= symfun(u-c, [u c])
ut = sym('u(c)')
The second line implies that u is a function of c, but you did not tell MATLAB that before you created f. You created f as if u is a variable, but in the second line you are talking about u as a function. What is it?
syms u(c)
f = symfun(u(c)-c, [u, c])

1 Comment

Hi,
u is a function of c, but I get the right answer, so the program see that f is a function of u(c) and c, from my code when I differentiate wrt c:
diff(u(c), c) - 1 == 0
What I simply want is to solve afterward for diff(u(c), c) to get :
diff(u(c), c) == 1
Thanks for the help.
Jerome

Sign in to comment.

Categories

Asked:

on 2 Dec 2015

Commented:

on 3 Dec 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!