simplify works differently on a variable having symbolic expression and on an absolute symbolic expression.
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 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
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!