How do I define implicit functions to be differentiated with the symbolic toolbox?

14 views (last 30 days)
Im trying to define an implicit function x(t) in the symbolic toolbox which I then want to be able to differentiate with its own time derivative. E.g I want to be able to express a function which has x(t) as its variable and then be able to calculate d/dt(funk), d/dx(funk) and d/dx'(funk).
I have tried:
syms t
x=sym('x(t)');
funk=2*x;
funk_dt=diff(funk,t);
But this wont work when differentiating "funk" with respect to x since x is a function.
So instead I tried:
syms x t
X=sym('X(x,t)'); %X is a function of itself and of t
funk=2*X;
funk_dt=diff(funk,t);
funk_dx=diff(funk,x);
But when I try to take the derivative of "funk" with respect to d/dt(x), e.g.
funk_dxdt=diff(funk,diff(X,t))
this wont work since X is a function, not a variable.
If it helps with interpreting my question, what I want to do is calculate Lagrange's equations. Here I need to calculate:
d/dt(d(L)/d(q')) - d(L)/d(q)
where L is a function of q(t) and q' is the time derivative of q(t).
Grateful for any help!
/Erik

Answers (0)

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!