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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by