simplify works differently on a variable having symbolic expression and on an absolute symbolic expression.
Mostra commenti meno recenti
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?
Risposte (1)
Walter Roberson
il 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
1 Commento
Malay Tushar Nagda
il 26 Nov 2019
Categorie
Scopri di più su Symbolic Math Toolbox in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!