Simplifiy function incorrect result?

2 views (last 30 days)
Hello,
I ran into a problem using Matlab simplify function. I have the following code:
syms q1 q2 q3 real
syms l3 l4 real
Ja = [-sin(q1)*(l3*cos(q2)+l4*cos(q2+q3)), -cos(q1)*(l3*sin(q2)+l4*sin(q2+q3)), -l4*cos(q1)*sin(q2+q3)
cos(q1)*(l3*cos(q2)+l4*cos(q2+q3)), -sin(q1)*(l3*sin(q2)+l4*sin(q2+q3)), -l4*sin(q1)*sin(q2+q3)
0, -l3*cos(q2)-l4*cos(q2+q3), -l4*cos(q2+q3)];
detJa = det(Ja);
simplify(detJa)
this code returns:
l3*l4*(l3*cos(q2)*sin(q3) - l4*sin(q2) + l4*cos(q3)^2*sin(q2) + l4*cos(q2)*cos(q3)*sin(q3))
If I calculate this by hand, I get the following result:
l3*l4*sin(q3)*(l3*cos(q2)+l4*cos(q2+q3))
I am pretty sure that this is the correct answer, but why does simplifiy return a different result?
Thanks in advance for any help

Accepted Answer

Star Strider
Star Strider on 20 May 2019
You just need to tell simplify to keep simplifying:
DetJa = simplify(detJa, 'Steps',500)
producing:
DetJa =
l3*l4*sin(q3)*(l4*cos(q2 + q3) + l3*cos(q2))

More Answers (1)

Aston Martin
Aston Martin on 22 May 2019
Thanks a lot! :)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!