Clear Filters
Clear Filters

Solve funcion shows empty syms variables as result

2 views (last 30 days)
Hi all!
I am spotting another error in my matlab program! My code should carry out a simple system of equations, that I have written as matrices. I've used 'syms' variable to initialize the variables that I should find, and then I've employed 'solve' function to compute the equations.
More precisely, here's the code:
clear r11 r12 r13 r21 r22 r23 r31 r32 r33 tx ty tz
syms r11 r12 r13 r21 r22 r23 r31 r32 r33 tx ty tz
R=[r11 r12 r12; r21 r22 r23; r31 r32 r33];
t=[tx; ty; tz];
eqn1= ip==R*ic+t;
eqn2= mp==R*mc+t;
eqn3= rp==R*rc+t;
eqn4= lp==R*lc+t;
sol=solve([eqn1(:); eqn2(:); eqn3(:); eqn4(:)]);
Unfortunately, the solution returns me empty variables. For example, when I type "r11" in the command window to display its value, the solution is "r11=r11". I have the same error also adding "'ReturnConditions', true" as condition of the function, or using vpasolve instead of solve, or specifying the variables with respect to solve the function (R and t).
Where i am mistaken?
Thank you very much!

Accepted Answer

Walter Roberson
Walter Roberson on 23 Feb 2019
you are asking to solve 4 equation in 12 variables but you do not specify which variables to solve for . You need to indicate four variables to solve for.
The results will be returned in the struct sol so if r11 was asked to be solved for you would examine sol.r11
  6 Comments
Walter Roberson
Walter Roberson on 24 Feb 2019
Code Attached.
The answers will be in fields of the structure sol
alessiadele
alessiadele on 25 Feb 2019
thank you for your help Walter :)
I've tried your code, but it still returns me empty solutions: I've discovered that the problems are the values of *p and *c, in fact carrying out the equations manually, I've noticed that there's no solution! Unfortunately, there's a sort of incompatibility.
Thank you again! I'll sign your answer as right, so someone else could read the post and have some help!

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements 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!