How can I get a derivated function df/dt?

36 views (last 30 days)
Hello,
I'm trying to calculate derivate functions like z(t)=cos(x(t))+y(t)^2 and I expect answers like z'(t)=-x'(t)*sin(x(t))+2*y(t)*y'(t).
I probably need to use MuPAD but I don't know the commands and what I've found on 'help' isn't exactrly what I want.
Thanks for your answers!

Accepted Answer

Star Strider
Star Strider on 7 Aug 2015
In R2015a, I get this result:
syms x(t) y(t) z(t)
z(t)=cos(x(t))+y(t)^2;
dzdt = diff(z, t)
dzdt(t) =
2*y(t)*diff(y(t), t) - sin(x(t))*diff(x(t), t)
  1 Comment
Star Strider
Star Strider on 7 Aug 2015
It depends on whether it is an additive or multiplicative constant, and where it is in the expression.
Example 1 (multiplicative):
syms x(t) y(t) z(t) c
z(t) = c * cos(x(t)) + y(t)^2;
dzdt = diff(z, t)
dzdt(t) =
2*y(t)*diff(y(t), t) - c*sin(x(t))*diff(x(t), t)
Example 2 (additive):
syms x(t) y(t) z(t) c
z(t) = c + cos(x(t)) + y(t)^2;
dzdt = diff(z, t)
dzdt(t) =
2*y(t)*diff(y(t), t) - sin(x(t))*diff(x(t), t)
As expected, it disappears if an additive constant.
Example 3 (multiplicative inside expression):
syms x(t) y(t) z(t) c
z(t) = cos(c*x(t)) + y(t)^2;
dzdt = diff(z, t)
dzdt(t) =
2*y(t)*diff(y(t), t) - c*sin(c*x(t))*diff(x(t), t)
Example 4 (additive inside expression):
syms x(t) y(t) z(t) c
z(t) = cos(c + x(t)) + y(t)^2;
dzdt = diff(z, t)
dzdt(t) =
2*y(t)*diff(y(t), t) - sin(c + x(t))*diff(x(t), t)
One of these should work for you.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!