Solve funcion shows empty syms variables as result

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!

 Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Feb. de 2019

0 votos

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 comentarios

alessiadele
alessiadele el 23 de Feb. de 2019
Editada: alessiadele el 23 de Feb. de 2019
I'm not sure I have understood correctly; you mean that writing something like:
sol=solve([eqn1(:); eqn2(:); eqn3(:); eqn4(:)], R, t);
it is not enough? I should specify the variables for each equation of the system?
I had missed that t is a vector when you add it to each of your 4 equations. I also missed that your R uses r12 twice and does not use r13. So really what you have is 36 equations in either 11 variables or 19 variables (the other 8 being the *p and *c variables)
Now, two of the equations are
ip = tx + ic*r11
ip = tx + ic*r21
the only way that can happen is if r11 == r21 . There are other similar forced equivalences.
If you isolate tx, ty, tz, r11, r21, r31, r22, r32, r12, r23, r33, lc, rc (in that order) then you are reduced to a set of identity equations without having isolated ic, ip, mc, mp.
alessiadele
alessiadele el 24 de Feb. de 2019
Editada: alessiadele el 24 de Feb. de 2019
Thank you Walter, but actually I am a little bit confused.
I know ip, mp, rp, lp, ic, mc, rc and lc, that are all 3x1 vectors. So I have 12 equations and 12 variables to find out: it should work!
I've tried to separate equations and don't write them as matrices, in this way:
Eqn1= ic(1,1)*r11+ic(2,1)*r12+ic(3,1)*r13+tx == ip(1,1);
Eqn2= ic(1,1)*r21+ic(2,1)*r22+ic(3,1)*r23+ty == ip(2,1);
Eqn3= ic(1,1)*r31+ic(2,1)*r32+ic(3,1)*r33+tz == ip(3,1);
Eqn4= mc(1,1)*r11+mc(2,1)*r12+mc(3,1)*r13+tx == mp(1,1);
Eqn5= mc(1,1)*r21+mc(2,1)*r22+mc(3,1)*r23+ty == mp(2,1);
Eqn6= mc(1,1)*r31+mc(2,1)*r32+mc(3,1)*r33+tz == mp(3,1);
Eqn7= rc(1,1)*r11+rc(2,1)*r12+rc(3,1)*r13+tx == rp(1,1);
Eqn8= rc(1,1)*r21+rc(2,1)*r22+rc(3,1)*r23+ty == rp(2,1);
Eqn9= rc(1,1)*r31+rc(2,1)*r32+rc(3,1)*r33+tz == rp(3,1);
Eqn10= lc(1,1)*r11+lc(2,1)*r12+lc(3,1)*r13+tx == lp(1,1);
Eqn11= lc(1,1)*r21+lc(2,1)*r22+lc(3,1)*r23+ty == lp(2,1);
Eqn12= lc(1,1)*r31+lc(2,1)*r32+lc(3,1)*r33+tz == lp(3,1);
sol1= solve(Eqn1, [r11 r12 r13 tx]);
sol2= solve(Eqn2, [r21 r22 r23 ty]);
sol3= solve(Eqn3, [r31 r32 r33 tz]);
sol4= solve(Eqn4, [r11 r12 r13 tx]);
sol5= solve(Eqn5, [r21 r22 r23 ty]);
sol6= solve(Eqn6, [r31 r32 r33 tz]);
sol7= solve(Eqn7, [r31 r32 r33 tz]);
sol8= solve(Eqn8, [r21 r22 r23 ty]);
sol9= solve(Eqn9, [r31 r32 r33 tz]);
sol10= solve(Eqn10, [r11 r12 r13 tx]);
sol11= solve(Eqn11, [r21 r22 r23 ty]);
sol12= solve(Eqn12, [r31 r32 r33 tz]);
But I'm sure that something is wrong, first of all because it seems a mess, and then because the solutions return different values of variables.. I mean, for example, I have 4 different values of r11 (for sol1, sol4, sol7 and sol10), but I should have just one value for each variable..
I am missing something, I am confusing variables and equations!
Code Attached.
The answers will be in fields of the structure sol
alessiadele
alessiadele el 25 de Feb. de 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!

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 23 de Feb. de 2019

Comentada:

el 25 de Feb. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by