simplify works differently on a variable having symbolic expression and on an absolute symbolic expression.
17 views (last 30 days)
Show older comments
x =
0.5000*a3*sin(q2 - q1 + q3) - 0.5000*a2*sin(q1 + q2) - 0.5000*a2*sin(q1 - q2) - 0.5000*a3*sin(q1 + q2 + q3)
x=simplify(x)
This gives the output as
x =
0.5000*a3*sin(q2 - q1 + q3) - 0.5000*a2*sin(q1 + q2) - 0.5000*a2*sin(q1 - q2) - 0.5000*a3*sin(q1 + q2 + q3)
But when you simplify the expression as
x=simplify(0.5000*a3*sin(q2 - q1 + q3) - 0.5000*a2*sin(q1 + q2) - 0.5000*a2*sin(q1 - q2) - 0.5000*a3*sin(q1 + q2 + q3))
The output is
x =
-sin(q1)*(a3*cos(q2 + q3) + a2*cos(q2))
How can I get the latter simplification using a variable?
0 Comments
Answers (1)
Walter Roberson
on 7 Nov 2019
syms q1 q2 q3 a1 a2 a3
half = sym('0.5000');
x = half*a3*sin(q2 - q1 + q3) - half*a2*sin(q1 + q2) - half*a2*sin(q1 - q2) - half*a3*sin(q1 + q2 + q3)
x = simplify(x)
gives the same expression as you are looking for.
How exactly are you getting the 0.5000 in the symbolic expressions? I suspect that those are not exactly 0.5000, that instead you are showing the vpa() output of expressions involving constants that are close to 1/2
See Also
Categories
Find more on Symbolic Math Toolbox 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!