Can I use d/dt or overdot notation for symbolic equations?

Using symbolic equations Matlab does some handy stuff like converting theta_1 to the greek symbol with the appropriate subscript. Is there a way to convert a derivative the same way? So that it will display as dtheta/dt or with an overdot (latex: \dot{\theta})?

5 Comments

syms y(t)
diff(y)
ans(t) = 
In the right places, is this what you want? Its just display though. No matter what, a picture. What matters is mathematics, NOT the picture of mathematics. How you display the mathematics is just fluff in the end.
The OP meant "y with a dot on its head" - usually used for greek characters.
The overdot isn’t an option, however it will display correctly otherwise —
syms theta_1(t)
deriv = diff(theta_1)
deriv(t) = 
.
Thanks @John D'Errico and @Star Strider that answers my question.
The reason I am using a live script in this case is to report the solutions to other people. Being able to tidy up the output like this saves me from having to restate everything with LateX equations. It is just fluff, but fluff is important sometimes!
@casey lapoint — Consider using the latex function. It could make things easier.

Sign in to comment.

 Accepted Answer

Define your derivative variables in your syms call, then use subs() to swap the symbols in the display:
syms theta(t) theta_dot
x = theta
y = diff(x,t)
y = subs(y,diff(theta,t), theta_dot)
If you have a lot of symbols to replace, use sets. Just be careful of the order in which you replace symbols: you should go from highest order derivative to lowest.
syms theta(t) theta_dot theta_ddot omega(t) omega_dot omega_ddot
x = omega + theta;
y = diff(x,t);
z = diff(x,t,t);
oldsyms = {diff(theta,t,t), diff(omega,t,t), diff(theta,t), diff(omega,t)};
newsyms = {theta_ddot, omega_ddot, theta_dot, omega_dot};
y = subs(y, oldsyms, newsyms)
z = subs(z, oldsyms, newsyms)

More Answers (0)

Categories

Asked:

on 7 Sep 2022

Answered:

on 24 Sep 2025

Community Treasure Hunt

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

Start Hunting!