How to not simplify symbolic expressions?
6 views (last 30 days)
Show older comments
Hi all,
For a course in Dynamics of Machines I've ran into an issue with the matlab symbolic toolbox. For a simple system I derive the constraint equations expressed in symbolic coordinates in a vector; an example of the eqs is:
sqrt((x2-x1)^2 + (y2-y1)^2)-2*sqrt(2)
This is the input code however matlab changes the equation to:
((x1-x2)^2 + (y1-y2)^2)^(1/2)-2*sqrt(2)
Which should give the same result, however I need the Jacobian of the contstraint vector which means signs will be incorrect in the Jacobian since matlab switched x1 and x2 around. Is there a way to prevent matlab from simplifying these symbolic expressions? Or another solution to this problem?
Thanks in advance!
6 Comments
David Goodmanson
on 29 Mar 2018
Edited: David Goodmanson
on 29 Mar 2018
Of course if the roles of x1 and x2 get swapped somehow, x1 <--> x2 before you take the jacobian but the functions stay the same, then there will be a sign change. Or if the functions are swapped and x1 and x2 stay the same.
Answers (0)
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!