simplify works differently on a variable having symbolic expression and on an absolute symbolic expression.

12 Ansichten (letzte 30 Tage)
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?

Antworten (1)

Walter Roberson
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
  1 Kommentar
Malay Tushar Nagda
Malay Tushar Nagda am 26 Nov. 2019
Matrix operations involving both numerical and symbolic values is the reason for 0.5000 in symbolic expression.
I ended up using entirely different solution for my university project of making a GUI based robotics toolbox.Thank you for your response and sorry for delayed reply.

Melden Sie sich an, um zu kommentieren.

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!

Translated by