Changing a symbolic differentiation term to a variable.
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Terek Zimmerman
le 7 Nov 2019
Modifié(e) : Terek Zimmerman
le 8 Nov 2019
The issue I have ran into is that I have taken a symbolic derivative and I am hoping to simpliy the naming format. This is a sample of the code that I am doing currently and the output I am getting.
Input:
syms t phi(t)
phi = phi(t);
M = [cos(phi) (-sin(phi)) 0
sin(phi) cos(phi) 0
0 0 1];
M_dot = diff(M,t)
Output:
M_dot =
[ -sin(phi(t))*diff(phi(t), t), -cos(phi(t))*diff(phi(t), t), 0]
[ cos(phi(t))*diff(phi(t), t), -sin(phi(t))*diff(phi(t), t), 0]
[ 0, 0, 0]
My goal is to be able to rename the "diff(phi(t),t)" so that it simplifies my longer matrices. I have tried the subs(s, new, old) function and it returned an error so I need to find a different way.
Let me know what you all think. Thank you.
1 commentaire
Réponse acceptée
Walter Roberson
le 8 Nov 2019
syms dphi_dt
subs(M_dot, diff(phi), dphi_dt)
However, if you have multiple derivative levels, this will not find them. For example if you had diff(phi,t,t) then this would leave that alone rather than constructing diff(dphi_dt,t) or diff(dphi_dt(t),t)
Also, be careful: differentiating the result with respect to t will treat dphi_dt as a constant unless you do
syms dphi_dt(t))
subs(M_dot, diff(phi), dphi_dt)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!