MATLAB: How to display constants in equation solving

constants,simultaneous linear equationssymbolic,

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)

Best 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.