Empty sym: 0-by-1

17 views (last 30 days)
Mohamad
Mohamad on 6 Mar 2023
Answered: Rasmita on 16 Mar 2023
I am trying to get the solve the equation-system, however i keep getting Empty sym: 0-by-1 as an answer
P1_DIC = [-12.82; -8.1331; 0.1719];
P2_DIC = [-0.6782; 12.0748; 0.8961];
P3_DIC = [-23.8363; 2.3239; -5.5797];
P4_DIC = [-13.3786; 14.0454; -0.4767];
P1_TG = [379; 354];
P2_TG = [438; 240];
P3_TG = [305; 294];
P4_TG = [372; 225];
v1_DIC = P4_DIC - P1_DIC;
v2_DIC = P2_DIC - P1_DIC;
v3_DIC = P3_DIC - P1_DIC;
syms alfa bta gama v1_3 v2_3 v3_3 a
v1_TG = [P4_TG(1)-P1_TG(1); P4_TG(2)-P1_TG(2); v1_3];
v2_TG = [P2_TG(1)-P1_TG(1); P2_TG(2)-P1_TG(2); v2_3];
v3_TG = [P3_TG(1)-P1_TG(1); P3_TG(2)-P1_TG(2); v3_3];
T11 = cos(alfa)*cos(bta);
T12 = cos(alfa)*sin(bta)*sin(gama)-sin(alfa)*cos(gama);
T13 = cos(alfa)*sin(bta)*cos(gama)+sin(alfa)*sin(gama);
T21 = sin(alfa)*cos(bta);
T22 = sin(alfa)*sin(bta)*sin(gama)+cos(alfa)*cos(bta);
T23 = sin(alfa)*sin(bta)*cos(gama)-cos(alfa)*sin(gama);
T31 = -sin(bta);
T32 = cos(bta)*sin(gama);
T33 = cos(bta)*cos(gama);
eqn{1} = v1_TG(1)*T11 + v1_TG(2)*T12 + v1_TG(3)*T13 == v1_DIC(1);
eqn{2} = v1_TG(1)*T21 + v1_TG(2)*T22 + v1_TG(3)*T23 == v1_DIC(2);
eqn{3} = v1_TG(1)*T31 + v1_TG(2)*T32 + v1_TG(3)*T33 == v1_DIC(3);
eqn{4} = v2_TG(1)*T11 + v2_TG(2)*T12 + v2_TG(3)*T13 == v2_DIC(1);
eqn{5} = v2_TG(1)*T21 + v2_TG(2)*T22 + v2_TG(3)*T23 == v2_DIC(2);
eqn{6} = v2_TG(1)*T31 + v2_TG(2)*T32 + v2_TG(3)*T33 == v2_DIC(3);
eqn{7} = a^2 * norm(v3_TG)^2 == norm(v3_DIC)^2 ;
s = solve(eqn{1},eqn{2},eqn{3},eqn{4},eqn{5},eqn{6}, alfa, bta, gama, v1_3, v2_3, v3_3, a)
do you guys have an idea why?

Answers (1)

Rasmita
Rasmita on 16 Mar 2023
Hi,
It is my understanding that, you want to know why you are getting empty syms of 0-by-1 as output when solving above system of equations.
To find a numeric solution, you must give same number of equations as the number of variables in input to 'solve' function.
In this line of code:
s = solve(eqn{1},eqn{2},eqn{3},eqn{4},eqn{5},eqn{6}, alfa, bta, gama, v1_3, v2_3, v3_3, a)
write the inputs to the ‘solve’ function as an array of equations and an array of variables, like this:
s = solve([eqn{1},eqn{2},eqn{3},eqn{4},eqn{5},eqn{6}, eqn{7}], [alfa, bta, gama, v1_3, v2_3, v3_3, a])
After correcting above syntax also you might face the same issue because, the solver returns an empty solution of 0-by-1 syms when no solutions exist for that system of equations.
For more information on this, refer following documentation:
Hope this helps!
Regards,
Rasmita

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!