Problem with factoring a symbolic variable

11 ビュー (過去 30 日間)
MA
MA 2022 年 11 月 13 日
回答済み: Paul 2022 年 11 月 14 日
Hi. I have the following relatively simple symbolic equation, and I would like to calculate the terms that multiply Td_s. In this case, the result should be sin(T_s - T_u)*Td_s. However, I can't get this to work using "factor".
syms T_u T_t T_s tau_u Tdd_u Tdd_t Tdd_s Td_u Td_t Td_s;
eq = sin(T_s - T_u)*Td_s^2 + sin(T_t - T_u)*Td_t^2 - tau_u + (981*sin(T_u))/100 - Tdd_s*cos(T_s - T_u) - Tdd_t*cos(T_t - T_u);
factor(eq,Td_s)
  2 件のコメント
John D'Errico
John D'Errico 2022 年 11 月 13 日
編集済み: John D'Errico 2022 年 11 月 13 日
That seems to be a lot of effort, for a rather strange looking goal. You want to change the single term:
sin(T_s - T_u)*Td_s^2
into this one?
sin(T_s - T_u)*Td_s * Td_s
Any simplify will immediately combine the terms.
The simple answer is just to use the editor. Its just text in the end. So use the editor, since you know exactly what you want.
MA
MA 2022 年 11 月 14 日
Thanks. The problem comes up when trying to write a robot's equation in the "Manipulator form". To obtain the matrix C in those equations, we basically factor the derivatives of the independent variables.
https://robotacademy.net.au/lesson/rigid-body-dynamics/
But I'm probably trying to solve this using brute force and there is a better method to obtain that matrix.

サインインしてコメントする。

回答 (1 件)

Paul
Paul 2022 年 11 月 14 日
If only one term contains Td_s, then
syms T_u T_t T_s tau_u Tdd_u Tdd_t Tdd_s Td_u Td_t Td_s;
eq = sin(T_s - T_u)*Td_s^2 + sin(T_t - T_u)*Td_t^2 - tau_u + (981*sin(T_u))/100 - Tdd_s*cos(T_s - T_u) - Tdd_t*cos(T_t - T_u)
eq = 
c = children(eq);
c = c(has([c{:}],'Td_s'));
result = c/Td_s
result = 
Additional effort will be required if Td_s can show up as a coefficient in more than one term or if it can appear as part of a function argument.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by