How to solve for a derivative using symbols?
Show older comments
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)
Walter Roberson
on 3 Dec 2015
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
jerome
on 3 Dec 2015
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!