How I want to seperate the equation into Nw1a, Nw2a, Nw3a from NwA which Nw1a contains the variable q1(t),t and Nw2a contain variable q2(t),t and Nw3a contains variable q3(t)t

2 ビュー (過去 30 日間)
%Angular Velocity N to A
NwA=(sin(q3(t))*diff(q2(t), t) + cos(q2(t))*cos(q3(t))*diff(q1(t), t))*a1 + (cos(q3(t))*diff(q2(t), t) - cos(q2(t))*sin(q3(t))*diff(q1(t), t))*a2 + (sin(q2(t))*diff(q1(t), t) + diff(q3(t), t))*a3
I want to express this equation into partial angular velocity :
Nw1a = Contains all variable in q1(t),t
Nw2a = Contains all variable in q2(t),t
Nw3a = Contains all variable in q3(t),t
Already use function collect but doesn't work
collect ((sin(q3(t))*diff(q2(t), t) + cos(q2(t))*cos(q3(t))*diff(q1(t), t))*a1 + (cos(q3(t))*diff(q2(t), t)), [diff(q1(t), t)])
  2 件のコメント
Shivam Malviya
Shivam Malviya 2022 年 11 月 9 日
編集済み: Shivam Malviya 2022 年 11 月 9 日
Hi Syazana,
According to my understanding, you are trying to split the equation according to the variables.
But I have a query, whether the term containing two different variables, q1(t) and q2(t)), would go to Nw1a or Nw2a?
To understand better, I need the following information;
  1. A clear description of the result you want to achieve. An example output would help. In this case, what do you expect Nw1a, Nw2a, and Nw3a to be?
  2. Any relevant code.
The following ML Answer might be useful;
Thanks,
Shivam Malviya
Syazana
Syazana 2022 年 11 月 12 日
Hi Shivam Malviya,
This is my coding which NwA is the angular velocity of N to A
NwA=a1*(sin(q3(t))*diff(q2(t), t) + cos(q2(t))*cos(q3(t))*diff(q1(t), t)) + a2*(cos(q3(t))*diff(q2(t), t) - cos(q2(t))*sin(q3(t))*diff(q1(t), t)) + a3*(sin(q2(t))*diff(q1(t), t) + diff(q3(t), t))
I want to split the above equation become into this equation (Partial Angular Velocities) :
Nw1A= cos(q2(t))*cos(q3(t))*a1 - cos(q2(t))*sin(q3(t))*a2 + sin(q2(t))*a3
Nw2A=sin(q3(t))*a1 + cos(q3(t))*a2
Nw3A= a3
Nw1A is all the variable that contains diff(q1(t),t)
Nw2A is all the variable that contains diff(q2(t),t)
Nw3A is all the variable that contains diff(q3(t),t)
Thanks,
Syazana

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

採用された回答

Shivam Malviya
Shivam Malviya 2022 年 11 月 14 日
Hi Syazana,
It is my understanding that you want to split an equation according to the following subexpressions.
  • diff(q1(t), t)
  • diff(q2(t), t)
  • diff(q3(t), t)
The following script does the same.
syms q1(t) q2(t) q3(t) t
syms a1 a2 a3
NwA=(sin(q3(t))*diff(q2(t), t) + cos(q2(t))*cos(q3(t))*diff(q1(t), t))*a1 + (cos(q3(t))*diff(q2(t), t) - cos(q2(t))*sin(q3(t))*diff(q1(t), t))*a2 + (sin(q2(t))*diff(q1(t), t) + diff(q3(t), t))*a3;
% Expand the equations
NwA_expand = expand(NwA);
% Convert the equation into cell array of subexpressions
NwA_cell = children(NwA_expand);
% Convert cell array to array
NwA_array = [NwA_cell{:}];
% Split the equation based on the subexpression
Nw1A = sum(NwA_array(has(NwA_array, diff(q1(t), t)))) / diff(q1(t), t);
Nw2A = sum(NwA_array(has(NwA_array, diff(q2(t), t)))) / diff(q2(t), t);
Nw3A = sum(NwA_array(has(NwA_array, diff(q3(t), t)))) / diff(q3(t), t);
% Simplify the equations
Nw1A = simplify(Nw1A)
Nw1A = 
Nw2A = simplify(Nw2A)
Nw2A = 
Nw3A = simplify(Nw3A)
Nw3A = 
Hope this helps!
Regards,
Shivam Malviya
  1 件のコメント
Syazana
Syazana 2022 年 11 月 14 日
Hi Shivam Malviya,
This coding working very well as what I want! Thank you very much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by