0

I know there have been very similar questions to this on this forum and I have already gone through them and unfortunately I am not yet convinced of the result that I have achieved.

I am trying to solve a system of three simultaneous equations, but the catch is that all of the equations are symbolic and what I actually mean by 'solving the equations' is writing the 'symbolic unknowns' in terms of the rest of the symbols or the supposedly known values.

I have posted my code below and I have pretty much tried to apply one of the examples in the Mathworks website. What happens is the code runs and Matlab remains in the busy state for a very long time and then it ends up saying that it cannot solve the equation.

In other similar examples that I had seen, people had done something similar and peculiarly enough, no one complained about the long waiting time. Is this supposed to take a long time? What am I doing wrong or can change to get what I am after? Here is my code:

    L2 = sym('L2');
    L1 = sym('L1');
    L3 = sym('L3');
    theta1 = sym('theta1');
    theta2 = sym('theta2');
    theta3 = sym('theta3');
    x = sym('x');
    y = sym('y');
    z = sym('z');
    eqn1 = cos(theta1)*(L1 + L3*cos(theta2 + theta3) + L2*cos(theta2)) == x
    eqn2 = sin(theta1)*(L1 + L3*cos(theta2 + theta3) + L2*cos(theta2)) == y
    eqn3 = L3*sin(theta2 + theta3) + L2*sin(theta2) == z
    sol = solve([eqn1,eqn2,eqn3],[theta1,theta2,theta3]);
Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
Jamy codes
  • 101
  • 2
  • 8
  • Wait, why do you have that inequality? `==x`? doesnt make much sense – Ander Biguri May 12 '16 at 11:20
  • Without the `==` it takes time yes. Most likely because it doesnt have a solution, as it is incredibly non-linear. Not all equations can be solved mathematically, and yours look like some of those – Ander Biguri May 12 '16 at 11:21
  • Is not == an equality sign? That is how it was done on the relevant Matlab webpage. It does have a solution though. Those angles (theta1, theta2 and theta3) actually have geometric significance and I can find an expression for them geometrically. But, I was hoping Matlab can give me these angles in terms of the rest of the variables, based on the three equations. Moreover, I just want the angles in terms of the other variables not an exact value for solution. – Jamy codes May 12 '16 at 11:32

0 Answers0