How to get the symbolic partial time derivative

Let's say I have this function

f(t) = 4*sin(a(t)) + x(t)*y(t) + h + cos(y(t))*sin(x(t))

      

How to calculate its time derivative?

+3


source to share


1 answer


You need to declare the variables and functions inside it as symbolic and then use diff:

clear
clc

syms a x y t h

a(t) = symfun(sym('a(t)'), t)
x(t) = symfun(sym('x(t)'), t)
y(t) = symfun(sym('y(t)'), t)

F = 4*sin(a(t)) + x(t)*y(t) + h + cos(y(t))*sin(x(t))

DerF_t = diff(F,t)

      

Providing the following (messy) output:



F =   h + 4*sin(a(t)) + cos(y(t))*sin(x(t)) + x(t)*y(t)
DerF_t =   x(t)*diff(y(t), t) + y(t)*diff(x(t), t) + 4*cos(a(t))*diff(a(t), t) + cos(x(t))*cos(y(t))*diff(x(t), t) - sin(x(t))*sin(y(t))*diff(y(t), t)

      

Note that since a (t), x (t), and y (t) are simply defined as functions of t, we get stuck with their "symbolic" derivative (I don't know ... ie diff (a (t )), eg.

Hope you were!

+6


source







All Articles