- 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?
- Any relevant code.
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
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;
The following ML Answer might be useful;
Thanks,
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)
Nw2A = simplify(Nw2A)
Nw3A = simplify(Nw3A)
Hope this helps!
Regards,
Shivam Malviya
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!