- 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
1 view (last 30 days)
Show older comments
%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 Comments
Shivam Malviya
on 9 Nov 2022
Edited: Shivam Malviya
on 9 Nov 2022
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
Accepted Answer
Shivam Malviya
on 14 Nov 2022
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
More Answers (0)
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!