The following example demonstrates how you can represent "x" as functions of time "t" and perform differentation on it:
Example 1:
syms t
x = sym('x(t)');
E1 = diff(x) * sin(x)
E2 = diff(E1,t)
pretty(E1)
pretty(E2)
The solution for E1:
/d \
|-- x(t)| sin(x(t))
\dt /
The solution for E2:
/ 2 \
|d | /d \2
|--- x(t)| sin(x(t)) + |-- x(t)| cos(x(t))
| 2 | \dt /
\dt /
The following example demonstrates how to substitute 'x(t)' with an explicit definition.
Example 2:
n = 2
syms t
x = sym('t^2');
f = sym('f(x)');
f_subs = subs(f);
disp('Diff f_subs wrt to t')
pretty(diff(5*f_subs + t^2,t,n))
disp(' ')
disp('Diff f_subs wrt to x(t)')
pretty(diff(5*f_subs + t^2,x,n))
disp(' ')
Best Answer