How to display constants in equation solving

The solution of simultaneous linear equations does not include the characters declared as constants.
Please tell me how to display the constants of the solution as they are.
(I'm using the symbolic math toolbox)

2 Comments

KK posted as an Answer —
I'm not used to using Matlab.
Please scrutinize the file
Are you saying that when you look at the solution for THETADDOT that you want to see names such as m_p in it ?

Sign in to comment.

 Accepted Answer

L =
(I_h*(diff(phi(t), t)^2 + diff(theta(t), t)^2))/2 + (m_b*((r*(diff(phi(t), t) + diff(theta(t), t)) + h*cos(phi(t))*diff(phi(t), t))^2 + h^2*sin(phi(t))^2*diff(phi(t), t)^2))/2 + (m_p*((r*(diff(phi(t), t) + diff(theta(t), t)) + H*cos(phi(t))*diff(phi(t), t) + l*cos(psi(t))*psi(1, t))^2 + (H*sin(phi(t))*diff(phi(t), t) + l*sin(psi(t))*psi(1, t))^2))/2 + (I_b*diff(phi(t), t)^2)/2 + (I_p*psi(1, t)^2)/2 + (m_h*r^2*(diff(phi(t), t)^2 + diff(theta(t), t)^2)^2)/2 - g*m_p*(h*cos(phi(t)) + l*cos(psi(t))) - g*h*m_b*cos(phi(t))
subs(L, theta, dum_)
ans =
(m_b*((r*diff(phi(t), t) + h*cos(phi(t))*diff(phi(t), t))^2 + h^2*sin(phi(t))^2*diff(phi(t), t)^2))/2 + (m_p*((H*sin(phi(t))*diff(phi(t), t) + l*sin(psi(t))*psi(1, t))^2 + (r*diff(phi(t), t) + H*cos(phi(t))*diff(phi(t), t) + l*cos(psi(t))*psi(1, t))^2))/2 + (I_b*diff(phi(t), t)^2)/2 + (I_h*diff(phi(t), t)^2)/2 + (I_p*psi(1, t)^2)/2 - g*m_p*(h*cos(phi(t)) + l*cos(psi(t))) + (m_h*r^2*diff(phi(t), t)^4)/2 - g*h*m_b*cos(phi(t))
Notice that theta disappeared when you did the subs(). The expression includes diff(theta(t),t) . When you subs(expression, theta, dum_) then that becomes diff(dum_,t) and since dum_ is not a function of t, that becomes 0 .
Which release are you using? Taking a derivative with respect to a simple function had support added in R2020b.

1 Comment

Thank you for your answer, Mr. Walter Roberson.
I am using R2020b.
Once I replaced theta with dum_, differentiated it, and changed dum_ back to theta.
Let's check again for any mistakes.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

KK
on 17 Dec 2020

Commented:

KK
on 18 Dec 2020

Community Treasure Hunt

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

Start Hunting!