How do I solve this set of equations using MATLAB?

1 visualización (últimos 30 días)
Goncalo Costa
Goncalo Costa el 8 de Nov. de 2022
Comentada: Torsten el 8 de Nov. de 2022
I am trying to solve the following equations for the variable :
and
for that I wrote the following:
syms M n_1 n_2 n_3 th1 th2 th3
eqns = [M == ( (n_2*cos(th2) - n_3*cos(th3))/(n_2*cos(th2) + n_3*cos(th3)) )*...
( (n_2*cos(th2) + n_1*cos(th1))/(n_2*cos(th2) - n_1*cos(th1)) ) , ...
n_1*sin(th1) == n_2*sin(th2) , n_1*sin(th1) == n_3*sin(th3) ];
S = solve(eqns, [n_2])
But when I run the code I get that:
Empty sym: 0-by-1
What have I done wrong? How do I solve multiple equations?

Respuestas (2)

Torsten
Torsten el 8 de Nov. de 2022
You want to solve for one unknown - thus you only need one of the two equations.
If you want to solve for n1, n2 and n3, you have to specify this is the solve command.
But MATLAB cannot find an analytical solution, as you can see below.
syms M n_1 n_2 n_3 th1 th2 th3
eqns = [M == ( (n_2*cos(th2) - n_3*cos(th3))/(n_2*cos(th2) + n_3*cos(th3)) )*...
( (n_2*cos(th2) + n_1*cos(th1))/(n_2*cos(th2) - n_1*cos(th1)) ) , ...
n_1*sin(th1) == n_2*sin(th2) , n_1*sin(th1) == n_3*sin(th3) ];
S = solve(eqns, [n_1,n_2,n_3])
S = struct with fields:
n_1: [0×1 sym] n_2: [0×1 sym] n_3: [0×1 sym]
  5 comentarios
John D'Errico
John D'Errico el 8 de Nov. de 2022
I would note there is pretty much never an analytical solution to a problem, where a variable appears both inside and outside of a trig function. Thus anything of the general form x*sin(x) = c, will generally have no algebraic/analytical solution, even if it has a numerical solution.
Torsten
Torsten el 8 de Nov. de 2022
And this is the case somewhere ? The n_i are all outside the trig expressions.

Iniciar sesión para comentar.


Torsten
Torsten el 8 de Nov. de 2022
As you can see from the below analysis, there is only the solution n_1 = n_2 = n_3 = 0 without conditions on the angles th1, th2 and th3.
syms M n_1 n_2 n_3 th1 th2 th3
f = M *(n_2*cos(th2) + n_3*cos(th3))*(n_2*cos(th2) - n_1*cos(th1)) - (n_2*cos(th2) - n_3*cos(th3))*(n_2*cos(th2) + n_1*cos(th1));
f = subs(f,[n_2 n_3],[n_1*sin(th1)/sin(th2),n_1*sin(th1)/sin(th3)])
f = 
f = simplify(f)
f = 

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by