How do I symbolically work with implicit functions (i.e., "x(t)") within the Symbolic Math Toolbox?
40 views (last 30 days)
I would like to find the derivative of:
E1 = x' * sin(x)
where "x" and "y" are functions of time "t".
syms x t
I receive the result:
syms x y t
??? Unable to find subsindex function for class sym.
The following example demonstrates how you can represent "x" as functions of time "t" and perform differentation on it:
x = sym('x(t)'); % x(t)
E1 = diff(x) * sin(x)
E2 = diff(E1,t)
The solution for E1:
|-- x(t)| sin(x(t))
The solution for E2:
/ 2 \
|d | /d \2
|--- x(t)| sin(x(t)) + |-- x(t)| cos(x(t))
| 2 | \dt /
The following example demonstrates how to substitute 'x(t)' with an explicit definition.
% Order of the derivative
n = 2
% Define symbolic variables.
x = sym('t^2');
f = sym('f(x)');
% SUBS is used to substitute definition of x
f_subs = subs(f);
disp('Diff f_subs wrt to t')
pretty(diff(5*f_subs + t^2,t,n))
disp('Diff f_subs wrt to x(t)')
pretty(diff(5*f_subs + t^2,x,n))